From f48277f10da33334a144c35ba5c21a831863f670 Mon Sep 17 00:00:00 2001 From: Mike Mason Date: Fri, 11 Aug 2023 14:43:18 +0000 Subject: [PATCH] use nats source as connection label 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 --- events/nats_config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/events/nats_config.go b/events/nats_config.go index a528b78..1d9e926 100644 --- a/events/nats_config.go +++ b/events/nats_config.go @@ -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 }