Created
April 22, 2016 09:24
-
-
Save adriacidre/b2a908f810445fd4181c93f1914e15b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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