summaryrefslogtreecommitdiff
path: root/cmd/publisher
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/publisher')
-rw-r--r--cmd/publisher/main.go32
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)
+ }
+}