Skip to content

Commit

Permalink
feat: upgarde to go-common-service v0.8.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Simpson committed Dec 12, 2024
1 parent 23e9d10 commit d1543e7
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 68 deletions.
36 changes: 29 additions & 7 deletions cmd/gameserver-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"github.com/ShatteredRealms/gameserver-service/pkg/config"
"github.com/ShatteredRealms/gameserver-service/pkg/pb"
"github.com/ShatteredRealms/gameserver-service/pkg/srv"
"github.com/ShatteredRealms/go-common-service/pkg/bus"
"github.com/ShatteredRealms/go-common-service/pkg/bus/character/characterbus"
"github.com/ShatteredRealms/go-common-service/pkg/bus/gameserver/dimensionbus"
"github.com/ShatteredRealms/go-common-service/pkg/bus/gameserver/mapbus"
"github.com/ShatteredRealms/go-common-service/pkg/log"
commonpb "github.com/ShatteredRealms/go-common-service/pkg/pb"
commonsrv "github.com/ShatteredRealms/go-common-service/pkg/srv"
Expand All @@ -19,9 +23,11 @@ import (
)

func main() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
interruptCtx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()

ctx := context.Background()

// Load configuration and setup server context
cfg, err := config.NewGameServerConfig(ctx)
if err != nil {
Expand Down Expand Up @@ -67,6 +73,25 @@ func main() {
return
}

// Bus service
busService, err := commonsrv.NewBusServiceServer(
ctx,
*srvCtx.Context,
map[bus.BusMessageType]bus.Resettable{
characterbus.Message{}.GetType(): srvCtx.CharacterService.GetResetter(),
},
map[bus.BusMessageType]commonsrv.WriterResetCallback{
dimensionbus.Message{}.GetType(): srvCtx.ResetDimensionBus(),
mapbus.Message{}.GetType(): srvCtx.ResetMapBus(),
},
)
commonpb.RegisterBusServiceServer(grpcServer, busService)
err = commonpb.RegisterBusServiceHandlerFromEndpoint(ctx, gwmux, cfg.Server.Address(), opts)
if err != nil {
log.Logger.WithContext(ctx).Errorf("register bus service handler endpoint: %v", err)
return
}

// Dimension Service
dimensionService, err := srv.NewDimensionServiceServer(ctx, srvCtx)
if err != nil {
Expand Down Expand Up @@ -96,19 +121,16 @@ func main() {
// Setup Complete
log.Logger.WithContext(ctx).Info("Initializtion complete")
span.End()

srvErr := make(chan error, 1)
go func() {
srvErr <- util.StartServer(ctx, grpcServer, gwmux, cfg.Server.Address())
}()
srv, srvErr := util.StartServer(ctx, grpcServer, gwmux, cfg.Server.Address())
defer srv.Shutdown(ctx)

select {
case err := <-srvErr:
if err != nil {
log.Logger.Error(err)
}

case <-ctx.Done():
case <-interruptCtx.Done():
log.Logger.Info("Server canceled by user input.")
stop()
}
Expand Down
29 changes: 15 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ module github.com/ShatteredRealms/gameserver-service
go 1.23.3

require (
github.com/ShatteredRealms/go-common-service v0.6.11
github.com/ShatteredRealms/go-common-service v0.8.20
github.com/WilSimpson/gocloak/v13 v13.11.2
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0
github.com/mitranim/gow v0.0.0-20231026105220-af11a6e1e9eb
github.com/onsi/ginkgo/v2 v2.22.0
github.com/solo-io/protoc-gen-openapi v0.2.5
github.com/spf13/cobra-cli v1.3.0
go.uber.org/mock v0.5.0
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697
google.golang.org/grpc v1.68.0
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576
google.golang.org/grpc v1.68.1
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1
google.golang.org/protobuf v1.35.2
k8s.io/api v0.31.0
Expand Down Expand Up @@ -47,6 +47,7 @@ require (
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/plugin/soft_delete v1.2.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 // indirect
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect
Expand All @@ -72,7 +73,7 @@ require (
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/pprof v0.0.0-20241122213907-cbe949e5a41b // indirect
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
Expand All @@ -86,7 +87,7 @@ require (
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
Expand Down Expand Up @@ -129,18 +130,18 @@ require (
go.opentelemetry.io/otel/trace v1.32.0
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/crypto v0.30.0 // indirect
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.27.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
golang.org/x/tools v0.28.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/postgres v1.5.10 // indirect
Expand Down
Loading

0 comments on commit d1543e7

Please sign in to comment.