Documentation
¶
Index ¶
- func NewHealthServiceServer(bdb bun.IDB, rdb rueidis.Client) grpc_health_v1.HealthServer
- type GRPCHandler
- type GRPCHandlerOption
- func WithCorsOptions(opts cors.Options) GRPCHandlerOption
- func WithLoggingInterceptor(logger logging.Logger) GRPCHandlerOption
- func WithOTELStatsHandler(tp trace.TracerProvider, mp metric.MeterProvider) GRPCHandlerOption
- func WithRecoveryInterceptor(f recovery.RecoveryHandlerFuncContext) GRPCHandlerOption
- func WithRegistrations(regs ...any) GRPCHandlerOption
- func WithSecureInterceptor(auth *secure.ServerAuthorizer, matcher selector.Matcher) GRPCHandlerOption
- func WithServeMuxRoutes(routes ...ServerMuxRoute) GRPCHandlerOption
- func WithStaticFileHandler(pattern string, sfs fs.FS) GRPCHandlerOption
- func WithStreamInterceptors(ints ...grpc.StreamServerInterceptor) GRPCHandlerOption
- func WithUnaryInterceptors(ints ...grpc.UnaryServerInterceptor) GRPCHandlerOption
- func WithValidatorInterceptor() GRPCHandlerOption
- type GatewayClientRegister
- type GatewayClientRegisterFunc
- type HTTPServer
- type Server
- type ServerMuxRoute
- type ServerServiceRegister
- type ServerServiceRegisterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHealthServiceServer ¶
func NewHealthServiceServer(bdb bun.IDB, rdb rueidis.Client) grpc_health_v1.HealthServer
NewHealthServiceServer returns a new health service server.
Types ¶
type GRPCHandler ¶
type GRPCHandler struct {
// contains filtered or unexported fields
}
GRPCHandler is an implementation of http.Handler for gRPC.
func NewGRPCHandler ¶
func NewGRPCHandler(cfg config.ServerHTTPConfig, opts ...GRPCHandlerOption) (*GRPCHandler, error)
NewGRPCHandler returns a new GRPCHandler with the given config and options.
func (*GRPCHandler) ServeHTTP ¶
func (h *GRPCHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
type GRPCHandlerOption ¶
type GRPCHandlerOption func(*GRPCHandler) error
GRPCHandlerOption is an option for GRPCHandler, used to configure it.
func WithCorsOptions ¶
func WithCorsOptions(opts cors.Options) GRPCHandlerOption
WithCorsOptions returns a GRPCHandlerOption that sets cors options for grpc gateway.
func WithLoggingInterceptor ¶
func WithLoggingInterceptor(logger logging.Logger) GRPCHandlerOption
WithLoggingInterceptor returns a GRPCHandlerOption that adds a logging interceptor to grpc handler.
func WithOTELStatsHandler ¶
func WithOTELStatsHandler(tp trace.TracerProvider, mp metric.MeterProvider) GRPCHandlerOption
WithOTELStatsHandler returns a GRPCHandlerOption that use an opentelemetry stats handler for grpc server.
func WithRecoveryInterceptor ¶
func WithRecoveryInterceptor(f recovery.RecoveryHandlerFuncContext) GRPCHandlerOption
WithRecoveryInterceptor returns a GRPCHandlerOption that adds a recovery interceptor to grpc handler. The given recovery handler will be called when a panic occurs.
func WithRegistrations ¶
func WithRegistrations(regs ...any) GRPCHandlerOption
WithRegistrations returns a GRPCHandlerOption that registers grpc servers and gateway clients. The given registrations must implement ServerServiceRegister or GatewayClientRegister.
func WithSecureInterceptor ¶
func WithSecureInterceptor(auth *secure.ServerAuthorizer, matcher selector.Matcher) GRPCHandlerOption
WithSecureInterceptor returns a GRPCHandlerOption that adds a secure interceptor to grpc handler. The given matcher will be used to determine which methods should be secured.
func WithServeMuxRoutes ¶
func WithServeMuxRoutes(routes ...ServerMuxRoute) GRPCHandlerOption
WithServeMuxRoutes returns a GRPCHandlerOption that adds routes to grpc gateway.
func WithStaticFileHandler ¶
func WithStaticFileHandler(pattern string, sfs fs.FS) GRPCHandlerOption
WithStaticFileHandler returns a GRPCHandlerOption that adds a static file handler to grpc gateway.
func WithStreamInterceptors ¶
func WithStreamInterceptors(ints ...grpc.StreamServerInterceptor) GRPCHandlerOption
WithStreamInterceptors returns a GRPCHandlerOption that adds the given stream interceptors to grpc handler.
func WithUnaryInterceptors ¶
func WithUnaryInterceptors(ints ...grpc.UnaryServerInterceptor) GRPCHandlerOption
WithUnaryInterceptors returns a GRPCHandlerOption that adds the given unary interceptors to grpc handler.
func WithValidatorInterceptor ¶
func WithValidatorInterceptor() GRPCHandlerOption
WithValidatorInterceptor returns a GRPCHandlerOption that adds a validator interceptor to grpc handler.
type GatewayClientRegister ¶
type GatewayClientRegister interface {
RegisterGatewayClient(context.Context, *runtime.ServeMux, *grpc.ClientConn) error
}
GatewayClientRegister is implemented by servers that register grpc gateway clients.
type GatewayClientRegisterFunc ¶
GatewayClientRegisterFunc is a function that registers grpc gateway clients.
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer is an implementation of Server for HTTP.
func NewHTTPServer ¶
func NewHTTPServer(cfg config.ServerHTTPConfig, logger logging.Logger, handler http.Handler) *HTTPServer
NewHTTPServer returns a new HTTPServer with the given config, logger, and handler.
func (*HTTPServer) Done ¶
func (s *HTTPServer) Done() <-chan error
type Server ¶
type Server interface { // Start starts the server. Start(context.Context) error // Stop stops the server. Stop(context.Context) error // Done returns a channel that is closed when the server is stopped. // An error is sent to the channel if the server is stopped with an error. Done() <-chan error }
Server is implemented by servers.
type ServerMuxRoute ¶
type ServerMuxRoute struct { // Methods is a list of HTTP methods, which are allowed for the route. Methods []string // Pattern is a URL pattern, which is used for matching the route. Pattern string // Handler is a handler function, which is called when the route is matched. Handler runtime.HandlerFunc }
ServerMuxRoute represents a route for server mux of gRPC-Gateway server.
type ServerServiceRegister ¶
type ServerServiceRegister interface {
RegisterServerService(grpc.ServiceRegistrar)
}
ServerServiceRegister is implemented by servers that register grpc services.
type ServerServiceRegisterFunc ¶
type ServerServiceRegisterFunc func(grpc.ServiceRegistrar)
ServerServiceRegisterFunc is a function that registers grpc services.