Skip to content

Commit

Permalink
Exit when permanently disconnected from Nats (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbubudi authored Jul 31, 2019
1 parent 6047ed5 commit 3daeb42
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cmd/publisher/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ func NewPublisherCommand() *cobra.Command {
natsURL := viper.GetString("nats-url")
natsClusterID := viper.GetString("nats-cluster-id")
natsClientID := viper.GetString("nats-client-id")
nats, err := stan.Connect(natsClusterID, natsClientID, stan.NatsURL(natsURL))
nats, err := stan.Connect(
natsClusterID,
natsClientID,
stan.NatsURL(natsURL),
stan.SetConnectionLostHandler(func(conn stan.Conn, err error) {
log.Fatal(err)
}),
)
if err != nil {
log.Fatal(err)
}
Expand Down
9 changes: 8 additions & 1 deletion cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ func NewServerCommand() *cobra.Command {
natsClusterID := viper.GetString("nats-cluster-id")
natsClientID := viper.GetString("nats-client-id")
bindAddress := viper.GetString("bind-address")
nats, err := stan.Connect(natsClusterID, natsClientID, stan.NatsURL(natsURL))
nats, err := stan.Connect(
natsClusterID,
natsClientID,
stan.NatsURL(natsURL),
stan.SetConnectionLostHandler(func(conn stan.Conn, err error) {
log.Fatal(err)
}),
)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 3daeb42

Please sign in to comment.