Skip to content

Instantly share code, notes, and snippets.

@adriacidre
Created April 22, 2016 09:24
Show Gist options
  • Save adriacidre/b2a908f810445fd4181c93f1914e15b5 to your computer and use it in GitHub Desktop.
Save adriacidre/b2a908f810445fd4181c93f1914e15b5 to your computer and use it in GitHub Desktop.
nc, _ := nats.Connect(nats.DefaultURL)
body := []byte(`{"status":"verification_pending", "verification_done"}`)
msg, err := nc.Request("workflow.get.next", body, 10*time.Millisecond)
nc.Close();
nc, _ := nats.Connect(nats.DefaultURL)
nc.Subscribe("workflow.get.next", func(m *Msg) {
workflow := loadWorkflow("config.json")
status, event, err := prepare(m.Data)
if err != nil {
nc.Publish(m.Reply, []byte("error"))
return
}
if next, err := workflow.getNext(status, event); err != nil {
nc.Publish(m.Reply, []byte(next))
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment