start implementing gw serve mux support

This commit is contained in:
2025-03-24 12:43:53 -04:00
parent 3e319b24fd
commit 4e014d5ea0
11 changed files with 227 additions and 161 deletions

33
pkg/srv/grpc/services.go Normal file
View File

@ -0,0 +1,33 @@
package grpc
import (
"context"
"fmt"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/grpc/opts"
)
func (a *appGRPCServer) registerGRPCServices(ctx context.Context) {
ctx, span := a.tracer.Start(ctx, "appgrpc.init.prepare.services", trace.WithAttributes(
attribute.Int("numServices", len(a.opts.Services)),
))
defer span.End()
for _, service := range a.opts.Services {
a.registerGRPCService(ctx, service)
a.registerServiceGatewayHandlers(ctx, service)
}
span.SetStatus(codes.Ok, "")
}
func (a *appGRPCServer) registerGRPCService(ctx context.Context, service *opts.GRPCService) {
span := trace.SpanFromContext(ctx)
span.AddEvent(fmt.Sprintf("registered %s service", service.Name))
a.server.RegisterService(service.Type, service.Service)
}