start implementing gw serve mux support
This commit is contained in:
		
							
								
								
									
										33
									
								
								pkg/srv/grpc/services.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								pkg/srv/grpc/services.go
									
									
									
									
									
										Normal 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) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user