init panel-service

This commit is contained in:
2023-09-27 16:13:48 +01:00
parent 55a533c461
commit e0bd8ef953
24 changed files with 2602 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
package main
import (
"context"
"github.com/rs/zerolog"
"github.com/hexolan/panels/panel-service/internal"
"github.com/hexolan/panels/panel-service/internal/postgres"
"github.com/hexolan/panels/panel-service/internal/redis"
"github.com/hexolan/panels/panel-service/internal/kafka"
"github.com/hexolan/panels/panel-service/internal/rpc"
"github.com/hexolan/panels/panel-service/internal/service"
)
func main() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
// Load the configuration
cfg := internal.NewConfig()
zerolog.SetGlobalLevel(cfg.GetLogLevel())
// Loading the dependencies
ctx := context.Background()
db := postgres.NewPostgresInterface(ctx, cfg)
rdb := redis.NewRedisInterface(ctx, cfg)
events := kafka.NewPanelEventProducer(cfg)
// Create the repositories and services
databaseRepo := postgres.NewPanelRepository(db)
cacheRepo := redis.NewPanelRepository(rdb, databaseRepo)
service := service.NewPanelService(events, cacheRepo)
// Create and serve RPC
rpcServer := rpc.NewRPCServer(service)
rpcServer.Serve()
}

View File

@@ -0,0 +1,12 @@
//go:build tools
package main
import (
// Protobuf Generation
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
// DB Migrations
_ "github.com/golang-migrate/migrate/v4"
_ "github.com/golang-migrate/migrate/v4/database/postgres"
)