From f9ec4d40accf0bea1c8e49e7d10677a01d298c08 Mon Sep 17 00:00:00 2001 From: Mike Mason Date: Fri, 11 Aug 2023 14:40:11 -0500 Subject: [PATCH] use nats source as connection label (#135) 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 }