Skip to content

Instantly share code, notes, and snippets.

@jasonblanchard
Created June 28, 2020 16:51
Show Gist options
  • Save jasonblanchard/2cae270bc61c438cdb3fdfd9b98d7027 to your computer and use it in GitHub Desktop.
Save jasonblanchard/2cae270bc61c438cdb3fdfd9b98d7027 to your computer and use it in GitHub Desktop.
ch := make(chan *nats.Msg, 64)
_, err = nc.ChanSubscribe("insights.get.velocity", ch)
if err != nil {
panic(err)
}
go func() {
for {
msg := <-ch
fmt.Print("Receiving in channel: ")
fmt.Println(string(msg.Data))
}
}()
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT)
go func() {
// Wait for signal
<-c
nc.Drain()
os.Exit(0)
}()
runtime.Goexit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment