Created
June 28, 2020 16:51
-
-
Save jasonblanchard/2cae270bc61c438cdb3fdfd9b98d7027 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
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