Skip to content

Commit

Permalink
feat(manager): add crud for source (#136)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohsen Haghgoo <[email protected]>
  • Loading branch information
mohsenHa and Mohsen Haghgoo authored Oct 26, 2024
1 parent 25809b3 commit a5219d9
Show file tree
Hide file tree
Showing 52 changed files with 2,029 additions and 723 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

ROOT=$(realpath $(dir $(lastword $(MAKEFILE_LIST))))

OS := $(shell uname -s)

lint:
which golangci-lint || (go install github.com/golangci/golangci-lint/cmd/[email protected])
golangci-lint run --config=$(ROOT)/.golangci.yml $(ROOT)/...
Expand All @@ -15,6 +17,9 @@ docker-test-up:
docker-test-down:
docker compose -f $(ROOT)/deployment/test/docker-compose.yml down

docker-local-up:
sh -c "$(ROOT)/deployment/local/docker-compose.bash up -d"

logs:
docker compose -f $(ROOT)/deployment/test/docker-compose.yml logs

Expand Down
31 changes: 24 additions & 7 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ import (

"github.com/ormushq/ormus/config"
"github.com/ormushq/ormus/logger"
"github.com/ormushq/ormus/manager"
"github.com/ormushq/ormus/manager/delivery/httpserver"
"github.com/ormushq/ormus/manager/delivery/httpserver/projecthandler"
"github.com/ormushq/ormus/manager/delivery/httpserver/sourcehandler"
"github.com/ormushq/ormus/manager/delivery/httpserver/userhandler"
"github.com/ormushq/ormus/manager/managerparam"
"github.com/ormushq/ormus/manager/repository/scyllarepo"
"github.com/ormushq/ormus/manager/repository/scyllarepo/scyllaproject"
"github.com/ormushq/ormus/manager/repository/scyllarepo/scyllasource"
"github.com/ormushq/ormus/manager/repository/scyllarepo/scyllauser"
"github.com/ormushq/ormus/manager/service/authservice"
"github.com/ormushq/ormus/manager/service/projectservice"
"github.com/ormushq/ormus/manager/service/sourceservice"
"github.com/ormushq/ormus/manager/service/userservice"
"github.com/ormushq/ormus/manager/validator/projectvalidator"
"github.com/ormushq/ormus/manager/validator/sourcevalidator"
"github.com/ormushq/ormus/manager/validator/uservalidator"
"github.com/ormushq/ormus/manager/workers"
"github.com/ormushq/ormus/pkg/channel"
Expand All @@ -42,11 +47,19 @@ func main() {
logger.L().Debug("start manger")
cfg := config.C().Manager
done := make(chan bool)
wg := sync.WaitGroup{}
wg := &sync.WaitGroup{}
logger.L().Debug(fmt.Sprintf("%+v", cfg))
logger.L().Debug(fmt.Sprintf("%+v", cfg.ScyllaDBConfig))

internalBroker := simple.New(done, &wg)
svcs := setupServices(wg, done, cfg)

server := httpserver.New(cfg, svcs)

server.Server()
}

func setupServices(wg *sync.WaitGroup, done <-chan bool, cfg manager.Config) httpserver.SetupServices {
internalBroker := simple.New(done, wg)
err := internalBroker.NewChannel(managerparam.CreateDefaultProject, channel.BothMode,
cfg.InternalBrokerConfig.ChannelSize, cfg.InternalBrokerConfig.NumberInstant, cfg.InternalBrokerConfig.MaxRetryPolicy)
if err != nil {
Expand All @@ -64,17 +77,21 @@ func main() {
projectSvc := projectservice.New(projectRepo, internalBroker, projectValidator)
projectHandler := projecthandler.New(authSvc, projectSvc)

sourceRepo := scyllasource.New(scylla)
sourceValidator := sourcevalidator.New(sourceRepo)
sourceSvc := sourceservice.New(sourceRepo, sourceValidator, projectSvc)
sourceHandler := sourcehandler.New(authSvc, sourceSvc)

userRepo := scyllauser.New(scylla)
userValidator := uservalidator.New(userRepo)
userSvc := userservice.New(authSvc, userRepo, internalBroker, userValidator)
userHand := userhandler.New(userSvc, projectSvc)

workers.New(projectSvc, internalBroker).Run(done, &wg)
workers.New(projectSvc, internalBroker).Run(done, wg)

server := httpserver.New(cfg, httpserver.SetupServicesResponse{
return httpserver.SetupServices{
UserHandler: userHand,
ProjectHandler: projectHandler,
})

server.Server()
SourceHandler: sourceHandler,
}
}
2 changes: 1 addition & 1 deletion contract/protobuf/source/source.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";

package source;
option go_package = "github.com/ormushq/ormus/contract/go/manager";
option go_package = "github.com/ormushq/ormus/contract/go/source";

import "google/protobuf/timestamp.proto";

Expand Down
Loading

0 comments on commit a5219d9

Please sign in to comment.