Documentation ¶
Overview ¶
Package grpc provides the backbone for a gRPC server with some opinionated defaults.
Index ¶
- type Option
- func WithContextExtender(contextExtender ...func(context.Context) context.Context) Option
- func WithForwardIncomingHeaders(headers ...string) Option
- func WithForwardOutgoingHeaders(headers ...string) Option
- func WithGRPCServerOption(serverOptions ...grpc.ServerOption) Option
- func WithGRPCWebOption(grpcWebOptions ...grpcweb.Option) Option
- func WithRuntimeServeMuxOption(serveMuxOptions ...runtime.ServeMuxOption) Option
- func WithStatsHandler(handler ...stats.Handler) Option
- func WithStreamInterceptor(interceptor ...grpc.StreamServerInterceptor) Option
- func WithUnaryInterceptor(interceptor ...grpc.UnaryServerInterceptor) Option
- type Server
- func (s *Server) AddContextExtender(contextExtender ...func(context.Context) context.Context)
- func (s *Server) AddStatsHandler(handler ...stats.Handler)
- func (s *Server) AddStreamInterceptor(interceptor ...grpc.StreamServerInterceptor)
- func (s *Server) AddUnaryInterceptor(interceptor ...grpc.UnaryServerInterceptor)
- func (s *Server) GracefulStop() error
- func (s *Server) LoopbackConn() *grpc.ClientConn
- func (s *Server) Serve(lis net.Listener) error
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) ServeLoopback() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an option for the gRPC server.
func WithContextExtender ¶
WithContextExtender adds functions that extend request contexts.
func WithForwardIncomingHeaders ¶
WithForwardIncomingHeaders makes the gRPC gateway forward the given request headers.
func WithForwardOutgoingHeaders ¶
WithForwardOutgoingHeaders makes the gRPC gateway forward the given response headers.
func WithGRPCServerOption ¶
func WithGRPCServerOption(serverOptions ...grpc.ServerOption) Option
WithGRPCServerOption adds serverOptions. The options UnaryInterceptor, StreamInterceptor and StatsHandler should not be used.
func WithGRPCWebOption ¶
WithGRPCWebOption adds grpcWebOptions.
func WithRuntimeServeMuxOption ¶
func WithRuntimeServeMuxOption(serveMuxOptions ...runtime.ServeMuxOption) Option
WithRuntimeServeMuxOption adds serveMuxOptions.
func WithStatsHandler ¶
WithStatsHandler adds stats handlers.
func WithStreamInterceptor ¶
func WithStreamInterceptor(interceptor ...grpc.StreamServerInterceptor) Option
WithStreamInterceptor adds stream interceptors.
func WithUnaryInterceptor ¶
func WithUnaryInterceptor(interceptor ...grpc.UnaryServerInterceptor) Option
WithUnaryInterceptor adds unary interceptors.
type Server ¶
type Server struct { Server *grpc.Server Web *grpcweb.WrappedGrpcServer Gateway *runtime.ServeMux Health *health.Server // contains filtered or unexported fields }
Server wraps the gRPC server, gRPC-gateway and a loopback connection.
func (*Server) AddContextExtender ¶
AddContextExtender adds functions that extend request contexts.
func (*Server) AddStatsHandler ¶
AddStatsHandler adds stats handlers.
func (*Server) AddStreamInterceptor ¶
func (s *Server) AddStreamInterceptor(interceptor ...grpc.StreamServerInterceptor)
AddStreamInterceptor adds stream interceptors.
func (*Server) AddUnaryInterceptor ¶
func (s *Server) AddUnaryInterceptor(interceptor ...grpc.UnaryServerInterceptor)
AddUnaryInterceptor adds unary interceptors.
func (*Server) GracefulStop ¶
GracefulStop stops the gRPC server gracefully.
func (*Server) LoopbackConn ¶
func (s *Server) LoopbackConn() *grpc.ClientConn
LoopbackConn returns an in-process gRPC connection to the server.
func (*Server) ServeLoopback ¶
ServeLoopback serves the gRPC server for the in-process gRPC connection.