Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(source): Implement Redis repository for writekey validation #102

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/manager/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ destination:
expiration: 0

manager:
grpc_service_address: ":8085"
http_address: ":8080"
internal_broker_config:
channel_size: 1000000
number_instant: 5
Expand Down
43 changes: 41 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package main

import (
"context"
"fmt"
"log/slog"
"os"
"os/signal"
"sync"
"syscall"
"time"

"github.com/ormushq/ormus/config"
"github.com/ormushq/ormus/logger"
"github.com/ormushq/ormus/manager/delivery/grpcserver"
"github.com/ormushq/ormus/manager/delivery/httpserver"
"github.com/ormushq/ormus/manager/delivery/httpserver/userhandler"
"github.com/ormushq/ormus/manager/managerparam"
"github.com/ormushq/ormus/manager/mockRepo/projectstub"
"github.com/ormushq/ormus/manager/repository/scyllarepo"
"github.com/ormushq/ormus/manager/repository/sourcerepo"
"github.com/ormushq/ormus/manager/service/authservice"
"github.com/ormushq/ormus/manager/service/projectservice"
"github.com/ormushq/ormus/manager/service/userservice"
Expand Down Expand Up @@ -53,9 +60,41 @@ func main() {
userHand := userhandler.New(userSvc, validateUserSvc, ProjectSvc)
workers.New(ProjectSvc, internalBroker).Run(done, &wg)

server := httpserver.New(cfg, httpserver.SetupServicesResponse{
httpServer := httpserver.New(cfg, httpserver.SetupServicesResponse{
UserHandler: userHand,
})

server.Server()
sourceRepo := sourcerepo.New(scylla)

grpcServer := grpcserver.New(sourceRepo, cfg)

if err := httpServer.Start(); err != nil {
logger.L().Error("Failed to start manager HTTP server", err)
os.Exit(1)
}

if err := grpcServer.Start(); err != nil {
logger.L().Error("Failed to start gRPC server", "error", err)
os.Exit(1)
}

quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt, syscall.SIGTERM)
<-quit
logger.L().Info("Shutting down manager server...")

const timeoutDuration = 10 * time.Second

ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration)
defer cancel()

if err := httpServer.Shutdown(ctx); err != nil {
logger.L().Error("manager HTTP server forced to shutdown", "error", err)
}

if err := grpcServer.Stop(ctx); err != nil {
logger.L().Error("manager gRPC server forced to shutdown", "error", err)
}

logger.L().Info("Server exiting")
}
Loading
Loading