Compare commits
	
		
			2 Commits
		
	
	
		
			v0.8.0
			...
			89f016ed9d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 89f016ed9d | |||
| 7f60a59d42 | 
							
								
								
									
										1
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO.md
									
									
									
									
									
								
							@@ -1,5 +1,6 @@
 | 
				
			|||||||
# TODO
 | 
					# TODO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- [ ] Test and troubleshoot GRPC Gateway supprot
 | 
				
			||||||
- [ ] Finish implementing GRPC service support
 | 
					- [ ] Finish implementing GRPC service support
 | 
				
			||||||
- [ ] Expand config test case to cover GRPC config
 | 
					- [ ] Expand config test case to cover GRPC config
 | 
				
			||||||
- [ ] Expand tracing
 | 
					- [ ] Expand tracing
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,9 +9,6 @@ import (
 | 
				
			|||||||
	"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
 | 
						"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: Make Configurable
 | 
					 | 
				
			||||||
const GRPC_GW_API_PATH = "/api"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (a *App) Done() <-chan any {
 | 
					func (a *App) Done() <-chan any {
 | 
				
			||||||
	return a.appDone
 | 
						return a.appDone
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@ func (a *App) runGRPC(ctx context.Context) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		a.HTTP.Handlers = append(a.HTTP.Handlers, opts.HTTPHandler{
 | 
							a.HTTP.Handlers = append(a.HTTP.Handlers, opts.HTTPHandler{
 | 
				
			||||||
			Prefix:      GRPC_GW_API_PATH,
 | 
								Prefix:      a.cfg.GRPC.GRPCGatewayPath,
 | 
				
			||||||
			StripPrefix: true,
 | 
								StripPrefix: true,
 | 
				
			||||||
			Handler:     a.GRPC.GetGatewayMux(),
 | 
								Handler:     a.GRPC.GetGatewayMux(),
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,4 +15,6 @@ type GRPCConfig struct {
 | 
				
			|||||||
	LogRequests           bool   `yaml:"logRequests" env:"APP_GRPC_LOG_REQUESTS" json:"logRequests,omitempty"`
 | 
						LogRequests           bool   `yaml:"logRequests" env:"APP_GRPC_LOG_REQUESTS" json:"logRequests,omitempty"`
 | 
				
			||||||
	EnableReflection      bool   `yaml:"enableReflection" env:"APP_GRPC_ENABLE_REFLECTION" json:"enableReflection,omitempty"`
 | 
						EnableReflection      bool   `yaml:"enableReflection" env:"APP_GRPC_ENABLE_REFLECTION" json:"enableReflection,omitempty"`
 | 
				
			||||||
	EnableInstrumentation bool   `yaml:"enableInstrumentation" env:"APP_GRPC_ENABLE_INSTRUMENTATION" json:"enableInstrumentation,omitempty"` // requires OTEL
 | 
						EnableInstrumentation bool   `yaml:"enableInstrumentation" env:"APP_GRPC_ENABLE_INSTRUMENTATION" json:"enableInstrumentation,omitempty"` // requires OTEL
 | 
				
			||||||
 | 
						EnableGRPCGateway     bool   `yaml:"enableGRPCGateway" json:"enableGRPCGateway,omitempty" env:"APP_GRPC_ENABLE_GATEWAY" default:"true"`
 | 
				
			||||||
 | 
						GRPCGatewayPath       string `yaml:"grpcGatewayPath" json:"grpcGatewayPath,omitempty" env:"APP_GRPC_GATEWAY_PATH" default:"/grpc-api"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"net"
 | 
						"net"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/grpc-ecosystem/grpc-gateway/runtime"
 | 
						"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
 | 
				
			||||||
	"go.opentelemetry.io/otel/attribute"
 | 
						"go.opentelemetry.io/otel/attribute"
 | 
				
			||||||
	"go.opentelemetry.io/otel/codes"
 | 
						"go.opentelemetry.io/otel/codes"
 | 
				
			||||||
	"go.opentelemetry.io/otel/trace"
 | 
						"go.opentelemetry.io/otel/trace"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@ import (
 | 
				
			|||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/grpc-ecosystem/grpc-gateway/runtime"
 | 
						"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
 | 
				
			||||||
	"github.com/rs/zerolog"
 | 
						"github.com/rs/zerolog"
 | 
				
			||||||
	"go.opentelemetry.io/otel/attribute"
 | 
						"go.opentelemetry.io/otel/attribute"
 | 
				
			||||||
	"go.opentelemetry.io/otel/codes"
 | 
						"go.opentelemetry.io/otel/codes"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@ package opts
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/grpc-ecosystem/grpc-gateway/runtime"
 | 
						"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
 | 
				
			||||||
	"google.golang.org/grpc"
 | 
						"google.golang.org/grpc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
 | 
						"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
 | 
				
			||||||
@@ -25,12 +25,14 @@ type AppGRPC struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type GRPCService struct {
 | 
					type GRPCService struct {
 | 
				
			||||||
	Name                string                                                             // Descriptive name of service
 | 
						Name                string               // Descriptive name of service
 | 
				
			||||||
	Type                *grpc.ServiceDesc                                                  // Type (from protoc generated code)
 | 
						Type                *grpc.ServiceDesc    // Type (from protoc generated code)
 | 
				
			||||||
	Service             any                                                                // Implementation of GRPCService.Type (ptr)
 | 
						Service             any                  // Implementation of GRPCService.Type (ptr)
 | 
				
			||||||
	GwRegistrationFuncs []func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error // Gateway regustration handler funcs
 | 
						GwRegistrationFuncs []GwRegistrationFunc // Gateway regustration handler funcs
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type GwRegistrationFunc func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (a *AppGRPC) SetGatewayMux(mux *runtime.ServeMux) {
 | 
					func (a *AppGRPC) SetGatewayMux(mux *runtime.ServeMux) {
 | 
				
			||||||
	a.gatewayMux = mux
 | 
						a.gatewayMux = mux
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,6 @@ import (
 | 
				
			|||||||
	semconv "go.opentelemetry.io/otel/semconv/v1.27.0"
 | 
						semconv "go.opentelemetry.io/otel/semconv/v1.27.0"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: Implement
 | 
					 | 
				
			||||||
func (a *appGRPCServer) runGRPCServer(spanCtx context.Context) error {
 | 
					func (a *appGRPCServer) runGRPCServer(spanCtx context.Context) error {
 | 
				
			||||||
	_, span := a.tracer.Start(spanCtx, "appgrpc.init.start")
 | 
						_, span := a.tracer.Start(spanCtx, "appgrpc.init.start")
 | 
				
			||||||
	defer span.End()
 | 
						defer span.End()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,9 @@ func (a *appGRPCServer) registerGRPCServices(ctx context.Context) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for _, service := range a.opts.Services {
 | 
						for _, service := range a.opts.Services {
 | 
				
			||||||
		a.registerGRPCService(ctx, service)
 | 
							a.registerGRPCService(ctx, service)
 | 
				
			||||||
		a.registerServiceGatewayHandlers(ctx, service)
 | 
							if a.opts.EnableGRPCGateway {
 | 
				
			||||||
 | 
								a.registerServiceGatewayHandlers(ctx, service)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	span.SetStatus(codes.Ok, "")
 | 
						span.SetStatus(codes.Ok, "")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user