Skip to content

Commit

Permalink
use nats source as connection label (#135)
Browse files Browse the repository at this point in the history
Nats supports providing a connection a name.
To help with troubleshooting we should set this name so it's clear which
connections are from which service.

We already have the Source field which defines the source in the
messages, so we can simply reuse this variable and add a conneciton
option to set the name.

Signed-off-by: Mike Mason <mimason@equinix.com>
  • Loading branch information
mikemrm authored Aug 11, 2023
1 parent 9391872 commit f9ec4d4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions events/nats_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ func (c NATSConfig) WithDefaults() NATSConfig {
c.connectOptions = append(c.connectOptions, nats.UserCredentials(c.CredsFile))
}

if c.Source != "" {
c.connectOptions = append(c.connectOptions, nats.Name(c.Source))
}

return c
}

Expand Down

0 comments on commit f9ec4d4

Please sign in to comment.