diff options
| author | mo khan <mo@mokhan.ca> | 2022-11-30 13:42:14 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2022-11-30 13:42:14 -0700 |
| commit | 3f82b3f43c33f8442d4c5d3afee732529595dada (patch) | |
| tree | a80f57ff2323a00c2cda096f27128804ba80fa59 /cmd/publisher | |
initial commitmain
Diffstat (limited to 'cmd/publisher')
| -rw-r--r-- | cmd/publisher/main.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cmd/publisher/main.go b/cmd/publisher/main.go new file mode 100644 index 0000000..24125b1 --- /dev/null +++ b/cmd/publisher/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "c0/gatekeeper/pkg/x" + "fmt" + "time" + + "github.com/gobuffalo/buffalo/worker" + "github.com/nats-io/nats.go" +) + +func main() { + connection := x.Must(nats.Connect(nats.DefaultURL)) + defer connection.Close() + + stream := x.Must(connection.JetStream()) + + for i := 0; 1 == 1; i++ { + reply := x.Must(stream.Publish("gtkpr.jobs.job_1", []byte(worker.Args{"message": i}.String()))) + fmt.Printf("job: %v %v\n", i, reply) + + if i%2 == 0 { + reply := x.Must(stream.Publish("gtkpr.event.even", []byte(worker.Args{"even": i}.String()))) + fmt.Printf("even: %v %v\n", i, reply) + } else { + reply := x.Must(stream.Publish("gtkpr.event.odd", []byte(worker.Args{"odd": i}.String()))) + fmt.Printf("odd: %v %v\n", i, reply) + } + + time.Sleep(1000 * time.Millisecond) + } +} |
