mirror of
https://github.com/hexolan/panels.git
synced 2026-03-26 12:40:21 +00:00
init post-service
This commit is contained in:
42
services/post-service/cmd/post-service/main.go
Normal file
42
services/post-service/cmd/post-service/main.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
||||
"github.com/hexolan/panels/post-service/internal"
|
||||
"github.com/hexolan/panels/post-service/internal/postgres"
|
||||
"github.com/hexolan/panels/post-service/internal/redis"
|
||||
"github.com/hexolan/panels/post-service/internal/kafka"
|
||||
"github.com/hexolan/panels/post-service/internal/kafka/producer"
|
||||
"github.com/hexolan/panels/post-service/internal/rpc"
|
||||
"github.com/hexolan/panels/post-service/internal/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||
|
||||
// Load the configuration
|
||||
cfg := internal.NewConfig()
|
||||
zerolog.SetGlobalLevel(cfg.GetLogLevel())
|
||||
|
||||
// Create the interface dependencies
|
||||
ctx := context.Background()
|
||||
db := postgres.NewPostgresInterface(ctx, cfg)
|
||||
rdb := redis.NewRedisInterface(ctx, cfg)
|
||||
events := producer.NewPostEventProducer(cfg)
|
||||
|
||||
// Create the repositories and services
|
||||
dbRepo := postgres.NewPostRepository(db)
|
||||
cacheRepo := redis.NewPostRepository(rdb, dbRepo)
|
||||
service := service.NewPostService(events, cacheRepo)
|
||||
|
||||
// Start the event consumers
|
||||
eventConsumers := kafka.NewEventConsumers(cfg, dbRepo, events)
|
||||
eventConsumers.Start()
|
||||
|
||||
// Create and serve RPC
|
||||
rpcServer := rpc.NewRPCServer(service)
|
||||
rpcServer.Serve()
|
||||
}
|
||||
12
services/post-service/cmd/post-service/tools.go
Normal file
12
services/post-service/cmd/post-service/tools.go
Normal 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"
|
||||
)
|
||||
Reference in New Issue
Block a user