From 952b77b3dbdcc4e3ddc6762c9c133d4ef02a06d0 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 30 Dec 2024 20:10:52 -0800 Subject: [PATCH] submissions: connect to maps grpc --- pkg/cmds/serve.go | 15 ++++++++++++++- pkg/service/service.go | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/cmds/serve.go b/pkg/cmds/serve.go index 690d553..ccab4cd 100644 --- a/pkg/cmds/serve.go +++ b/pkg/cmds/serve.go @@ -5,6 +5,7 @@ import ( "net/http" "git.itzana.me/strafesnet/go-grpc/auth" + "git.itzana.me/strafesnet/go-grpc/maps" "git.itzana.me/strafesnet/maps-service/pkg/api" "git.itzana.me/strafesnet/maps-service/pkg/datastore/gormstore" internal "git.itzana.me/strafesnet/maps-service/pkg/internal" @@ -77,6 +78,12 @@ func NewServeCommand() *cli.Command { EnvVars: []string{"AUTH_RPC_HOST"}, Value: "auth-service:8090", }, + &cli.StringFlag{ + Name: "data-rpc-host", + Usage: "Host of data rpc", + EnvVars: []string{"DATA_RPC_HOST"}, + Value: "data-service:9000", + }, &cli.StringFlag{ Name: "nats-host", Usage: "Host of nats", @@ -110,12 +117,18 @@ func serve(ctx *cli.Context) error { log.WithError(err).Fatal("failed to add stream") } + // connect to main game database + conn, err := grpc.Dial(ctx.String("data-rpc-host"), grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatal(err) + } svc := &service.Service{ DB: db, Nats: js, + Client: maps.NewMapsServiceClient(conn), } - conn, err := grpc.Dial(ctx.String("auth-rpc-host"), grpc.WithTransportCredentials(insecure.NewCredentials())) + conn, err = grpc.Dial(ctx.String("auth-rpc-host"), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Fatal(err) } diff --git a/pkg/service/service.go b/pkg/service/service.go index 36e9171..ac0c2f6 100644 --- a/pkg/service/service.go +++ b/pkg/service/service.go @@ -3,6 +3,8 @@ package service import ( "context" "errors" + + "git.itzana.me/strafesnet/go-grpc/maps" "git.itzana.me/strafesnet/maps-service/pkg/api" "git.itzana.me/strafesnet/maps-service/pkg/datastore" "github.com/nats-io/nats.go" @@ -18,6 +20,7 @@ var ( type Service struct { DB datastore.Datastore Nats nats.JetStreamContext + Client maps.MapsServiceClient } // NewError creates *ErrorStatusCode from error returned by handler.