main
1package main
2
3import (
4 "c0/gatekeeper/pkg/x"
5 "fmt"
6 "time"
7
8 "github.com/gobuffalo/buffalo/worker"
9 "github.com/nats-io/nats.go"
10)
11
12func main() {
13 connection := x.Must(nats.Connect(nats.DefaultURL))
14 defer connection.Close()
15
16 stream := x.Must(connection.JetStream())
17
18 for i := 0; 1 == 1; i++ {
19 reply := x.Must(stream.Publish("gtkpr.jobs.job_1", []byte(worker.Args{"message": i}.String())))
20 fmt.Printf("job: %v %v\n", i, reply)
21
22 if i%2 == 0 {
23 reply := x.Must(stream.Publish("gtkpr.event.even", []byte(worker.Args{"even": i}.String())))
24 fmt.Printf("even: %v %v\n", i, reply)
25 } else {
26 reply := x.Must(stream.Publish("gtkpr.event.odd", []byte(worker.Args{"odd": i}.String())))
27 fmt.Printf("odd: %v %v\n", i, reply)
28 }
29
30 time.Sleep(1000 * time.Millisecond)
31 }
32}