Skip to content

Commit

Permalink
feat: add name to NATS connections
Browse files Browse the repository at this point in the history
This facilitates debugging.
  • Loading branch information
smlx committed Mar 17, 2022
1 parent 999ab04 commit c2096c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/ssh-portal/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (cmd *ServeCmd) Run(log *zap.Logger) error {
defer stop()
// get nats server connection
nconn, err := nats.Connect(cmd.NATSServer,
nats.Name("ssh-portal"),
// exit on connection close
nats.ClosedHandler(func(_ *nats.Conn) {
log.Error("nats connection closed")
Expand Down
1 change: 1 addition & 0 deletions internal/sshportalapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func ServeNATS(ctx context.Context, stop context.CancelFunc, log *zap.Logger,
wg.Add(1)
// connect to NATS server
nconn, err := nats.Connect(natsURL,
nats.Name("ssh-portal-api"),
// synchronise exiting ServeNATS()
nats.ClosedHandler(func(_ *nats.Conn) {
log.Error("nats connection closed")
Expand Down

0 comments on commit c2096c7

Please sign in to comment.