// Package demo provides a reference implementation // of service.AppService. It packages out the GRPC and HTTP // functionality, for the sake of structure. package demo import ( "context" optsgrpc "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/grpc/opts" optshttp "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts" "gitea.libretechconsulting.com/rmcguire/go-server-with-otel/pkg/config" "gitea.libretechconsulting.com/rmcguire/go-server-with-otel/pkg/demo/demogrpc" "gitea.libretechconsulting.com/rmcguire/go-server-with-otel/pkg/demo/demohttp" "gitea.libretechconsulting.com/rmcguire/go-server-with-otel/pkg/service" ) type DemoService struct { ctx context.Context config *config.ServiceConfig http *demohttp.DemoHTTPServer grpc *demogrpc.DemoGRPCServer } func (d *DemoService) Init(ctx context.Context, config *config.ServiceConfig, ) (service.ShutdownFunc, error) { d.config = config d.ctx = ctx // These don't HAVE to be split into separate packages // This is, after all, a demo app. Just implement the interface. d.http = demohttp.NewDemoHTTPServer(ctx, config) d.grpc = demogrpc.NewDemoGRPCServer(ctx, config) // TODO: This should actually do shutdown stuff return func(_ context.Context) (string, error) { return "DemoService", nil }, nil } func (d *DemoService) GetGRPC() *optsgrpc.AppGRPC { return &optsgrpc.AppGRPC{ Services: d.grpc.GetServices(), GRPCDialOpts: d.grpc.GetDialOpts(), } } func (d *DemoService) GetHTTP() *optshttp.AppHTTP { return &optshttp.AppHTTP{ Ctx: d.ctx, Funcs: d.http.GetHandleFuncs(), HealthChecks: d.http.GetHealthCheckFuncs(), } }