From ed792362596a2da60c1269055feb8c0c90b8b0fd Mon Sep 17 00:00:00 2001 From: Dusan Borovcanin Date: Thu, 19 Dec 2024 18:10:14 +0100 Subject: [PATCH] Sync aliases in cmd Signed-off-by: Dusan Borovcanin --- cmd/bootstrap/main.go | 4 ++-- cmd/certs/main.go | 8 ++++---- cmd/coap/main.go | 10 +++++----- cmd/http/main.go | 4 ++-- cmd/invitations/main.go | 4 ++-- cmd/journal/main.go | 4 ++-- cmd/postgres-reader/main.go | 8 ++++---- cmd/postgres-writer/main.go | 8 ++++---- cmd/provision/main.go | 6 +++--- cmd/timescale-reader/main.go | 8 ++++---- cmd/timescale-writer/main.go | 8 ++++---- cmd/users/main.go | 4 ++-- cmd/ws/main.go | 8 ++++---- 13 files changed, 42 insertions(+), 42 deletions(-) diff --git a/cmd/bootstrap/main.go b/cmd/bootstrap/main.go index dc8af3baf3..45aa4eefc3 100644 --- a/cmd/bootstrap/main.go +++ b/cmd/bootstrap/main.go @@ -15,7 +15,7 @@ import ( chclient "github.com/absmach/callhome/pkg/client" "github.com/absmach/supermq" "github.com/absmach/supermq/bootstrap" - "github.com/absmach/supermq/bootstrap/api" + httpapi "github.com/absmach/supermq/bootstrap/api" "github.com/absmach/supermq/bootstrap/events/consumer" "github.com/absmach/supermq/bootstrap/events/producer" "github.com/absmach/supermq/bootstrap/middleware" @@ -179,7 +179,7 @@ func main() { exitCode = 1 return } - hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svc, authn, bootstrap.NewConfigReader([]byte(cfg.EncKey)), logger, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(svc, authn, bootstrap.NewConfigReader([]byte(cfg.EncKey)), logger, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) diff --git a/cmd/certs/main.go b/cmd/certs/main.go index 325561dbdb..6867928812 100644 --- a/cmd/certs/main.go +++ b/cmd/certs/main.go @@ -15,7 +15,7 @@ import ( chclient "github.com/absmach/callhome/pkg/client" "github.com/absmach/supermq" "github.com/absmach/supermq/certs" - "github.com/absmach/supermq/certs/api" + httpapi "github.com/absmach/supermq/certs/api" pki "github.com/absmach/supermq/certs/pki/amcerts" "github.com/absmach/supermq/certs/tracing" smqlog "github.com/absmach/supermq/logger" @@ -133,7 +133,7 @@ func main() { exitCode = 1 return } - hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svc, authn, logger, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(svc, authn, logger, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) @@ -159,9 +159,9 @@ func newService(tracer trace.Tracer, logger *slog.Logger, cfg config, pkiAgent p } sdk := mgsdk.NewSDK(config) svc := certs.New(sdk, pkiAgent) - svc = api.LoggingMiddleware(svc, logger) + svc = httpapi.LoggingMiddleware(svc, logger) counter, latency := prometheus.MakeMetrics(svcName, "api") - svc = api.MetricsMiddleware(svc, counter, latency) + svc = httpapi.MetricsMiddleware(svc, counter, latency) svc = tracing.New(svc, tracer) return svc diff --git a/cmd/coap/main.go b/cmd/coap/main.go index cdb52bad61..0ad2b73727 100644 --- a/cmd/coap/main.go +++ b/cmd/coap/main.go @@ -14,7 +14,7 @@ import ( chclient "github.com/absmach/callhome/pkg/client" "github.com/absmach/supermq" "github.com/absmach/supermq/coap" - "github.com/absmach/supermq/coap/api" + httpapi "github.com/absmach/supermq/coap/api" "github.com/absmach/supermq/coap/tracing" smqlog "github.com/absmach/supermq/logger" "github.com/absmach/supermq/pkg/grpcclient" @@ -147,14 +147,14 @@ func main() { svc = tracing.New(tracer, svc) - svc = api.LoggingMiddleware(svc, logger) + svc = httpapi.LoggingMiddleware(svc, logger) counter, latency := prometheus.MakeMetrics(svcName, "api") - svc = api.MetricsMiddleware(svc, counter, latency) + svc = httpapi.MetricsMiddleware(svc, counter, latency) - hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(cfg.InstanceID), logger) - cs := coapserver.NewServer(ctx, cancel, svcName, coapServerConfig, api.MakeCoAPHandler(svc, logger), logger) + cs := coapserver.NewServer(ctx, cancel, svcName, coapServerConfig, httpapi.MakeCoAPHandler(svc, logger), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) diff --git a/cmd/http/main.go b/cmd/http/main.go index 497d78f8bd..9b85de6d7a 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -20,7 +20,7 @@ import ( "github.com/absmach/mgate/pkg/session" "github.com/absmach/supermq" adapter "github.com/absmach/supermq/http" - "github.com/absmach/supermq/http/api" + httpapi "github.com/absmach/supermq/http/api" grpcChannelsV1 "github.com/absmach/supermq/internal/grpc/channels/v1" grpcClientsV1 "github.com/absmach/supermq/internal/grpc/clients/v1" smqlog "github.com/absmach/supermq/logger" @@ -166,7 +166,7 @@ func main() { svc := newService(pub, authn, clientsClient, channelsClient, logger, tracer) targetServerCfg := server.Config{Port: targetHTTPPort} - hs := httpserver.NewServer(ctx, cancel, svcName, targetServerCfg, api.MakeHandler(logger, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, targetServerCfg, httpapi.MakeHandler(logger, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) diff --git a/cmd/invitations/main.go b/cmd/invitations/main.go index eec7cc5c20..fc05a9caa9 100644 --- a/cmd/invitations/main.go +++ b/cmd/invitations/main.go @@ -16,7 +16,7 @@ import ( "github.com/absmach/supermq" grpcTokenV1 "github.com/absmach/supermq/internal/grpc/token/v1" "github.com/absmach/supermq/invitations" - "github.com/absmach/supermq/invitations/api" + httpapi "github.com/absmach/supermq/invitations/api" "github.com/absmach/supermq/invitations/middleware" invitationspg "github.com/absmach/supermq/invitations/postgres" smqlog "github.com/absmach/supermq/logger" @@ -156,7 +156,7 @@ func main() { return } - httpSvr := http.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svc, logger, authn, cfg.InstanceID), logger) + httpSvr := http.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(svc, logger, authn, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) diff --git a/cmd/journal/main.go b/cmd/journal/main.go index 93728c33fc..3b46ddcc15 100644 --- a/cmd/journal/main.go +++ b/cmd/journal/main.go @@ -15,7 +15,7 @@ import ( chclient "github.com/absmach/callhome/pkg/client" "github.com/absmach/supermq" "github.com/absmach/supermq/journal" - "github.com/absmach/supermq/journal/api" + httpapi "github.com/absmach/supermq/journal/api" "github.com/absmach/supermq/journal/events" "github.com/absmach/supermq/journal/middleware" journalpg "github.com/absmach/supermq/journal/postgres" @@ -157,7 +157,7 @@ func main() { return } - hs := http.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svc, authn, logger, svcName, cfg.InstanceID), logger) + hs := http.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(svc, authn, logger, svcName, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) diff --git a/cmd/postgres-reader/main.go b/cmd/postgres-reader/main.go index baa306d341..5157c9270d 100644 --- a/cmd/postgres-reader/main.go +++ b/cmd/postgres-reader/main.go @@ -22,7 +22,7 @@ import ( httpserver "github.com/absmach/supermq/pkg/server/http" "github.com/absmach/supermq/pkg/uuid" "github.com/absmach/supermq/readers" - "github.com/absmach/supermq/readers/api" + httpapi "github.com/absmach/supermq/readers/api" "github.com/absmach/supermq/readers/postgres" "github.com/caarlos0/env/v11" "github.com/jmoiron/sqlx" @@ -141,7 +141,7 @@ func main() { exitCode = 1 return } - hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(repo, authn, clientsClient, channelsClient, svcName, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(repo, authn, clientsClient, channelsClient, svcName, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) @@ -163,9 +163,9 @@ func main() { func newService(db *sqlx.DB, logger *slog.Logger) readers.MessageRepository { svc := postgres.New(db) - svc = api.LoggingMiddleware(svc, logger) + svc = httpapi.LoggingMiddleware(svc, logger) counter, latency := prometheus.MakeMetrics("postgres", "message_reader") - svc = api.MetricsMiddleware(svc, counter, latency) + svc = httpapi.MetricsMiddleware(svc, counter, latency) return svc } diff --git a/cmd/postgres-writer/main.go b/cmd/postgres-writer/main.go index 87361adc64..c6923b217b 100644 --- a/cmd/postgres-writer/main.go +++ b/cmd/postgres-writer/main.go @@ -16,7 +16,7 @@ import ( "github.com/absmach/supermq" "github.com/absmach/supermq/consumers" consumertracing "github.com/absmach/supermq/consumers/tracing" - "github.com/absmach/supermq/consumers/writers/api" + httpapi "github.com/absmach/supermq/consumers/writers/api" writerpg "github.com/absmach/supermq/consumers/writers/postgres" smqlog "github.com/absmach/supermq/logger" jaegerclient "github.com/absmach/supermq/pkg/jaeger" @@ -125,7 +125,7 @@ func main() { return } - hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svcName, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(svcName, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) @@ -147,8 +147,8 @@ func main() { func newService(db *sqlx.DB, logger *slog.Logger) consumers.BlockingConsumer { svc := writerpg.New(db) - svc = api.LoggingMiddleware(svc, logger) + svc = httpapi.LoggingMiddleware(svc, logger) counter, latency := prometheus.MakeMetrics("postgres", "message_writer") - svc = api.MetricsMiddleware(svc, counter, latency) + svc = httpapi.MetricsMiddleware(svc, counter, latency) return svc } diff --git a/cmd/provision/main.go b/cmd/provision/main.go index b4b93175f7..6c126a83bf 100644 --- a/cmd/provision/main.go +++ b/cmd/provision/main.go @@ -23,7 +23,7 @@ import ( httpserver "github.com/absmach/supermq/pkg/server/http" "github.com/absmach/supermq/pkg/uuid" "github.com/absmach/supermq/provision" - "github.com/absmach/supermq/provision/api" + httpapi "github.com/absmach/supermq/provision/api" "github.com/caarlos0/env/v11" "golang.org/x/sync/errgroup" ) @@ -84,10 +84,10 @@ func main() { SDK := mgsdk.NewSDK(SDKCfg) svc := provision.New(cfg, SDK, logger) - svc = api.NewLoggingMiddleware(svc, logger) + svc = httpapi.NewLoggingMiddleware(svc, logger) httpServerConfig := server.Config{Host: "", Port: cfg.Server.HTTPPort, KeyFile: cfg.Server.ServerKey, CertFile: cfg.Server.ServerCert} - hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svc, logger, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(svc, logger, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) diff --git a/cmd/timescale-reader/main.go b/cmd/timescale-reader/main.go index 9400828e75..ed5e22913a 100644 --- a/cmd/timescale-reader/main.go +++ b/cmd/timescale-reader/main.go @@ -22,7 +22,7 @@ import ( httpserver "github.com/absmach/supermq/pkg/server/http" "github.com/absmach/supermq/pkg/uuid" "github.com/absmach/supermq/readers" - "github.com/absmach/supermq/readers/api" + httpapi "github.com/absmach/supermq/readers/api" "github.com/absmach/supermq/readers/timescale" "github.com/caarlos0/env/v11" "github.com/jmoiron/sqlx" @@ -140,7 +140,7 @@ func main() { exitCode = 1 return } - hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(repo, authn, clientsClient, channelsClient, svcName, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(repo, authn, clientsClient, channelsClient, svcName, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) @@ -162,9 +162,9 @@ func main() { func newService(db *sqlx.DB, logger *slog.Logger) readers.MessageRepository { svc := timescale.New(db) - svc = api.LoggingMiddleware(svc, logger) + svc = httpapi.LoggingMiddleware(svc, logger) counter, latency := prometheus.MakeMetrics("timescale", "message_reader") - svc = api.MetricsMiddleware(svc, counter, latency) + svc = httpapi.MetricsMiddleware(svc, counter, latency) return svc } diff --git a/cmd/timescale-writer/main.go b/cmd/timescale-writer/main.go index 7173a3adc6..394abca9f2 100644 --- a/cmd/timescale-writer/main.go +++ b/cmd/timescale-writer/main.go @@ -16,7 +16,7 @@ import ( "github.com/absmach/supermq" "github.com/absmach/supermq/consumers" consumertracing "github.com/absmach/supermq/consumers/tracing" - "github.com/absmach/supermq/consumers/writers/api" + httpapi "github.com/absmach/supermq/consumers/writers/api" "github.com/absmach/supermq/consumers/writers/timescale" smqlog "github.com/absmach/supermq/logger" jaegerclient "github.com/absmach/supermq/pkg/jaeger" @@ -127,7 +127,7 @@ func main() { return } - hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svcName, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(svcName, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) @@ -149,8 +149,8 @@ func main() { func newService(db *sqlx.DB, logger *slog.Logger) consumers.BlockingConsumer { svc := timescale.New(db) - svc = api.LoggingMiddleware(svc, logger) + svc = httpapi.LoggingMiddleware(svc, logger) counter, latency := prometheus.MakeMetrics("timescale", "message_writer") - svc = api.MetricsMiddleware(svc, counter, latency) + svc = httpapi.MetricsMiddleware(svc, counter, latency) return svc } diff --git a/cmd/users/main.go b/cmd/users/main.go index ac52f62b79..77a8b172e5 100644 --- a/cmd/users/main.go +++ b/cmd/users/main.go @@ -36,7 +36,7 @@ import ( httpserver "github.com/absmach/supermq/pkg/server/http" "github.com/absmach/supermq/pkg/uuid" "github.com/absmach/supermq/users" - "github.com/absmach/supermq/users/api" + httpapi "github.com/absmach/supermq/users/api" "github.com/absmach/supermq/users/emailer" "github.com/absmach/supermq/users/events" "github.com/absmach/supermq/users/hasher" @@ -237,7 +237,7 @@ func main() { oauthProvider := googleoauth.NewProvider(oauthConfig, cfg.OAuthUIRedirectURL, cfg.OAuthUIErrorURL) mux := chi.NewRouter() - httpSrv := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(csvc, authn, tokenClient, cfg.SelfRegister, mux, logger, cfg.InstanceID, cfg.PassRegex, oauthProvider), logger) + httpSrv := httpserver.NewServer(ctx, cancel, svcName, httpServerConfig, httpapi.MakeHandler(csvc, authn, tokenClient, cfg.SelfRegister, mux, logger, cfg.InstanceID, cfg.PassRegex, oauthProvider), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) diff --git a/cmd/ws/main.go b/cmd/ws/main.go index c0eada29e9..699aadcb48 100644 --- a/cmd/ws/main.go +++ b/cmd/ws/main.go @@ -30,7 +30,7 @@ import ( httpserver "github.com/absmach/supermq/pkg/server/http" "github.com/absmach/supermq/pkg/uuid" "github.com/absmach/supermq/ws" - "github.com/absmach/supermq/ws/api" + httpapi "github.com/absmach/supermq/ws/api" "github.com/absmach/supermq/ws/tracing" "github.com/caarlos0/env/v11" "go.opentelemetry.io/otel/trace" @@ -167,7 +167,7 @@ func main() { svc := newService(clientsClient, channelsClient, nps, logger, tracer) - hs := httpserver.NewServer(ctx, cancel, svcName, targetServerConfig, api.MakeHandler(ctx, svc, logger, cfg.InstanceID), logger) + hs := httpserver.NewServer(ctx, cancel, svcName, targetServerConfig, httpapi.MakeHandler(ctx, svc, logger, cfg.InstanceID), logger) if cfg.SendTelemetry { chc := chclient.New(svcName, supermq.Version, logger, cancel) @@ -194,9 +194,9 @@ func main() { func newService(clientsClient grpcClientsV1.ClientsServiceClient, channels grpcChannelsV1.ChannelsServiceClient, nps messaging.PubSub, logger *slog.Logger, tracer trace.Tracer) ws.Service { svc := ws.New(clientsClient, channels, nps) svc = tracing.New(tracer, svc) - svc = api.LoggingMiddleware(svc, logger) + svc = httpapi.LoggingMiddleware(svc, logger) counter, latency := prometheus.MakeMetrics("ws_adapter", "api") - svc = api.MetricsMiddleware(svc, counter, latency) + svc = httpapi.MetricsMiddleware(svc, counter, latency) return svc }