This commit is contained in:
2026-10-01 16:42:39 +07:00
parent 5638349623
commit ee15d149bd
31 changed files with 37 additions and 88 deletions
-8
View File
@@ -81,7 +81,6 @@ const grpcMsgLimit = maxFileSize + (1 << 20)
func main() {
_ = godotenv.Load()
// PostgreSQL
dbpool, err := pgxpool.New(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatalf("Unable to create connection pool: %v\n", err)
@@ -164,13 +163,11 @@ func main() {
go participationService.RunParticipationEmails(context.Background(), emailSender, os.Getenv("PARTICIPATION_SECRET"), os.Getenv("GAME_TIMEZONE"))
go reviewService.RunReviewReminderEmails(context.Background(), emailSender)
// Create a listener on TCP port
lis, err := net.Listen("tcp", ":8080")
if err != nil {
log.Fatalln("Failed to listen:", err)
}
// Create a gRPC server object
s := grpc.NewServer(
grpc.MaxRecvMsgSize(grpcMsgLimit),
grpc.UnaryInterceptor(
@@ -205,7 +202,6 @@ func main() {
),
),
)
// Attach the Greeter service to the server
proto.RegisterEveningDetectiveServerServer(
s,
app.NewServer(
@@ -225,14 +221,11 @@ func main() {
),
)
// Serve gRPC server
log.Println("Serving gRPC on 0.0.0.0:8080")
go func() {
log.Fatalln(s.Serve(lis))
}()
// Create a client connection to the gRPC server we just started
// This is where the gRPC-Gateway proxies the requests
conn, err := grpc.NewClient(
"0.0.0.0:8080",
grpc.WithTransportCredentials(insecure.NewCredentials()),
@@ -288,7 +281,6 @@ func main() {
runtime.WithMarshalerOption("application/octet-stream", rawBody),
runtime.WithMarshalerOption("application/x-zip-compressed", rawBody),
)
// Register Greeter
err = proto.RegisterEveningDetectiveServerHandler(context.Background(), gwmux, conn)
if err != nil {
log.Fatalln("Failed to register gateway:", err)