Skip to content

Commit

Permalink
Sync aliases in cmd
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Borovcanin <[email protected]>
  • Loading branch information
dborovcanin committed Dec 19, 2024
1 parent 83ac810 commit ed79236
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions cmd/bootstrap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions cmd/certs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions cmd/coap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/invitations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/journal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions cmd/postgres-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
8 changes: 4 additions & 4 deletions cmd/postgres-writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions cmd/provision/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions cmd/timescale-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
8 changes: 4 additions & 4 deletions cmd/timescale-writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions cmd/users/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions cmd/ws/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand Down

0 comments on commit ed79236

Please sign in to comment.