From c0b4a5daa00cfc7c587e0b95f22f654a6c23fa04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Wed, 19 Mar 2025 10:29:01 +0100 Subject: [PATCH] chore: change constant name to camelcase --- pkg/generators/natsnames.go | 6 +++--- pkg/natsjsregistry/registry.go | 2 +- services/activitylog/pkg/command/server.go | 2 +- services/antivirus/pkg/service/service.go | 2 +- services/audit/pkg/command/server.go | 2 +- services/clientlog/pkg/command/server.go | 2 +- services/eventhistory/pkg/command/server.go | 2 +- services/frontend/pkg/command/events.go | 2 +- services/graph/pkg/server/http/server.go | 2 +- services/notifications/pkg/command/send_email.go | 2 +- services/notifications/pkg/command/server.go | 2 +- services/policies/pkg/command/server.go | 2 +- services/postprocessing/pkg/command/postprocessing.go | 2 +- services/postprocessing/pkg/service/service.go | 2 +- services/proxy/pkg/command/server.go | 2 +- services/search/pkg/service/grpc/v0/service.go | 2 +- services/sharing/pkg/revaconfig/config.go | 2 +- services/sse/pkg/command/server.go | 2 +- services/storage-users/pkg/event/event.go | 2 +- services/storage-users/pkg/revaconfig/config.go | 2 +- services/userlog/pkg/command/server.go | 2 +- 21 files changed, 23 insertions(+), 23 deletions(-) diff --git a/pkg/generators/natsnames.go b/pkg/generators/natsnames.go index 54fc15f72..a35c9d751 100644 --- a/pkg/generators/natsnames.go +++ b/pkg/generators/natsnames.go @@ -9,9 +9,9 @@ import ( type NType int const ( - NTYPE_BUS NType = iota - NTYPE_KEYVALUE - NTYPE_REGISTRY + NTypeBus NType = iota + NTypeKeyValue + NTypeRegistry ) func (n NType) String() string { diff --git a/pkg/natsjsregistry/registry.go b/pkg/natsjsregistry/registry.go index e183a36f8..8a98d6651 100644 --- a/pkg/natsjsregistry/registry.go +++ b/pkg/natsjsregistry/registry.go @@ -201,7 +201,7 @@ func (n *storeregistry) storeOptions(opts registry.Options) []store.Option { storeoptions = append(storeoptions, store.Nodes(addr...)) natsOptions := nats.GetDefaultOptions() - natsOptions.Name = generators.GenerateConnectionName(serviceName, generators.NTYPE_REGISTRY) + natsOptions.Name = generators.GenerateConnectionName(serviceName, generators.NTypeRegistry) natsOptions.User, natsOptions.Password = getAuth() natsOptions.ReconnectedCB = func(_ *nats.Conn) { if err := n.Init(); err != nil { diff --git a/services/activitylog/pkg/command/server.go b/services/activitylog/pkg/command/server.go index 32156d355..4c479956c 100644 --- a/services/activitylog/pkg/command/server.go +++ b/services/activitylog/pkg/command/server.go @@ -71,7 +71,7 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) evStream, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Events)) if err != nil { logger.Error().Err(err).Msg("Failed to initialize event stream") diff --git a/services/antivirus/pkg/service/service.go b/services/antivirus/pkg/service/service.go index 9c9e2cca1..6dea06db6 100644 --- a/services/antivirus/pkg/service/service.go +++ b/services/antivirus/pkg/service/service.go @@ -115,7 +115,7 @@ func (av Antivirus) Run() error { av.config.Events.TLSInsecure = false } - connName := generators.GenerateConnectionName(av.config.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(av.config.Service.Name, generators.NTypeBus) natsStream, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(av.config.Events)) if err != nil { return err diff --git a/services/audit/pkg/command/server.go b/services/audit/pkg/command/server.go index 99286f7eb..38727520b 100644 --- a/services/audit/pkg/command/server.go +++ b/services/audit/pkg/command/server.go @@ -37,7 +37,7 @@ func Server(cfg *config.Config) *cli.Command { ) defer cancel() - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) client, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Events)) if err != nil { return err diff --git a/services/clientlog/pkg/command/server.go b/services/clientlog/pkg/command/server.go index f4b70990e..9392f3a39 100644 --- a/services/clientlog/pkg/command/server.go +++ b/services/clientlog/pkg/command/server.go @@ -69,7 +69,7 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) s, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Events)) if err != nil { return err diff --git a/services/eventhistory/pkg/command/server.go b/services/eventhistory/pkg/command/server.go index 25f9eb048..7d4049191 100644 --- a/services/eventhistory/pkg/command/server.go +++ b/services/eventhistory/pkg/command/server.go @@ -56,7 +56,7 @@ func Server(cfg *config.Config) *cli.Command { m.BuildInfo.WithLabelValues(version.GetString()).Set(1) - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) consumer, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Events)) if err != nil { return err diff --git a/services/frontend/pkg/command/events.go b/services/frontend/pkg/command/events.go index 60d988330..d4ee94d0e 100644 --- a/services/frontend/pkg/command/events.go +++ b/services/frontend/pkg/command/events.go @@ -35,7 +35,7 @@ var _registeredEvents = []events.Unmarshaller{ // ListenForEvents listens for events and acts accordingly func ListenForEvents(ctx context.Context, cfg *config.Config, l log.Logger) error { - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) bus, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Events)) if err != nil { l.Error().Err(err).Msg("cannot connect to nats") diff --git a/services/graph/pkg/server/http/server.go b/services/graph/pkg/server/http/server.go index 2fe68b876..cfa43c231 100644 --- a/services/graph/pkg/server/http/server.go +++ b/services/graph/pkg/server/http/server.go @@ -57,7 +57,7 @@ func Server(opts ...Option) (http.Service, error) { if options.Config.Events.Endpoint != "" { var err error - connName := generators.GenerateConnectionName(options.Config.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(options.Config.Service.Name, generators.NTypeBus) eventsStream, err = stream.NatsFromConfig(connName, false, stream.NatsConfig(options.Config.Events)) if err != nil { options.Logger.Error(). diff --git a/services/notifications/pkg/command/send_email.go b/services/notifications/pkg/command/send_email.go index 857b699bc..c2582c3a0 100644 --- a/services/notifications/pkg/command/send_email.go +++ b/services/notifications/pkg/command/send_email.go @@ -32,7 +32,7 @@ func SendEmail(cfg *config.Config) *cli.Command { if !daily && !weekly { return errors.New("at least one of '--daily' or '--weekly' must be set") } - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) s, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Notifications.Events)) if err != nil { return err diff --git a/services/notifications/pkg/command/server.go b/services/notifications/pkg/command/server.go index 447a11bcb..ae14d9486 100644 --- a/services/notifications/pkg/command/server.go +++ b/services/notifications/pkg/command/server.go @@ -95,7 +95,7 @@ func Server(cfg *config.Config) *cli.Command { registeredEvents[typ.String()] = e } - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) client, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Notifications.Events)) if err != nil { return err diff --git a/services/policies/pkg/command/server.go b/services/policies/pkg/command/server.go index e70f06c93..ab671a84b 100644 --- a/services/policies/pkg/command/server.go +++ b/services/policies/pkg/command/server.go @@ -105,7 +105,7 @@ func Server(cfg *config.Config) *cli.Command { { - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) bus, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Events)) if err != nil { return err diff --git a/services/postprocessing/pkg/command/postprocessing.go b/services/postprocessing/pkg/command/postprocessing.go index 97a86d7cb..e8a63ddc4 100644 --- a/services/postprocessing/pkg/command/postprocessing.go +++ b/services/postprocessing/pkg/command/postprocessing.go @@ -41,7 +41,7 @@ func RestartPostprocessing(cfg *config.Config) *cli.Command { return configlog.ReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) stream, err := stream.NatsFromConfig(connName, false, stream.NatsConfig{ Endpoint: cfg.Postprocessing.Events.Endpoint, Cluster: cfg.Postprocessing.Events.Cluster, diff --git a/services/postprocessing/pkg/service/service.go b/services/postprocessing/pkg/service/service.go index f6af1d3b6..9fb8639d1 100644 --- a/services/postprocessing/pkg/service/service.go +++ b/services/postprocessing/pkg/service/service.go @@ -47,7 +47,7 @@ var ( // NewPostprocessingService returns a new instance of a postprocessing service func NewPostprocessingService(ctx context.Context, logger log.Logger, sto store.Store, tp trace.TracerProvider, cfg *config.Config) (*PostprocessingService, error) { - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) pub, err := stream.NatsFromConfig(connName, false, stream.NatsConfig{ Endpoint: cfg.Postprocessing.Events.Endpoint, Cluster: cfg.Postprocessing.Events.Cluster, diff --git a/services/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index 6046b9fab..14b96513e 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -158,7 +158,7 @@ func Server(cfg *config.Config) *cli.Command { var publisher events.Stream if cfg.Events.Endpoint != "" { var err error - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) publisher, err = stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Events)) if err != nil { logger.Error(). diff --git a/services/search/pkg/service/grpc/v0/service.go b/services/search/pkg/service/grpc/v0/service.go index ca25d93b2..32a76843e 100644 --- a/services/search/pkg/service/grpc/v0/service.go +++ b/services/search/pkg/service/grpc/v0/service.go @@ -116,7 +116,7 @@ func NewHandler(opts ...Option) (searchsvc.SearchProviderHandler, func(), error) // setup event handling - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) stream, err := raw.FromConfig(context.Background(), connName, raw.Config{ Endpoint: cfg.Events.Endpoint, Cluster: cfg.Events.Cluster, diff --git a/services/sharing/pkg/revaconfig/config.go b/services/sharing/pkg/revaconfig/config.go index ac7d7afbd..c790ded10 100644 --- a/services/sharing/pkg/revaconfig/config.go +++ b/services/sharing/pkg/revaconfig/config.go @@ -136,7 +136,7 @@ func SharingConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string] "tls-insecure": cfg.Events.TLSInsecure, "tls-root-ca-cert": cfg.Events.TLSRootCaCertPath, "enable-tls": cfg.Events.EnableTLS, - "name": generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS), + "name": generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus), "username": cfg.Events.AuthUsername, "password": cfg.Events.AuthPassword, }, diff --git a/services/sse/pkg/command/server.go b/services/sse/pkg/command/server.go index 7607a7ce7..27fbd576c 100644 --- a/services/sse/pkg/command/server.go +++ b/services/sse/pkg/command/server.go @@ -53,7 +53,7 @@ func Server(cfg *config.Config) *cli.Command { } { - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) natsStream, err := stream.NatsFromConfig(connName, true, stream.NatsConfig(cfg.Events)) if err != nil { return err diff --git a/services/storage-users/pkg/event/event.go b/services/storage-users/pkg/event/event.go index e699ca2da..d296c8f5a 100644 --- a/services/storage-users/pkg/event/event.go +++ b/services/storage-users/pkg/event/event.go @@ -9,7 +9,7 @@ import ( // NewStream prepares the requested nats stream and returns it. func NewStream(cfg *config.Config) (events.Stream, error) { - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) return stream.NatsFromConfig(connName, false, stream.NatsConfig{ Endpoint: cfg.Events.Addr, Cluster: cfg.Events.ClusterID, diff --git a/services/storage-users/pkg/revaconfig/config.go b/services/storage-users/pkg/revaconfig/config.go index c4ea5b969..0df2a8516 100644 --- a/services/storage-users/pkg/revaconfig/config.go +++ b/services/storage-users/pkg/revaconfig/config.go @@ -58,7 +58,7 @@ func StorageUsersConfigFromStruct(cfg *config.Config) map[string]interface{} { "tls-insecure": cfg.Events.TLSInsecure, "tls-root-ca-cert": cfg.Events.TLSRootCaCertPath, "enable-tls": cfg.Events.EnableTLS, - "name": generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS), + "name": generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus), "username": cfg.Events.AuthUsername, "password": cfg.Events.AuthPassword, }, diff --git a/services/userlog/pkg/command/server.go b/services/userlog/pkg/command/server.go index 7147d9120..b75e9f7ef 100644 --- a/services/userlog/pkg/command/server.go +++ b/services/userlog/pkg/command/server.go @@ -77,7 +77,7 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() - connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTYPE_BUS) + connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) stream, err := stream.NatsFromConfig(connName, false, stream.NatsConfig(cfg.Events)) if err != nil { return err