Documentation
¶
Index ¶
- Variables
- func APIPrefix(prefix string) grpc.ServerOption
- func Address(addr string) grpc.ServerOption
- func ContextStreamInterceptor(f func(context.Context) (context.Context, error)) grpc.StreamServerInterceptor
- func ContextUnaryInterceptor(f func(context.Context) (context.Context, error)) grpc.UnaryServerInterceptor
- func GateWayOpts(opts ...runtime.ServeMuxOption) grpc.ServerOption
- func Handler(pathPrefix string, h http.Handler) grpc.ServerOption
- func Listener(lis net.Listener) grpc.ServerOption
- func Logger(logger logger) grpc.ServerOption
- func Middlewares(mdws ...middleware) grpc.ServerOption
- func NotFoundHandler(h http.Handler) grpc.ServerOption
- func OnShutdown(f func()) grpc.ServerOption
- func ShutdownTimeout(d time.Duration) grpc.ServerOption
- func TLS(certFile, keyFile string) grpc.ServerOption
- func Timeout(read, write time.Duration) grpc.ServerOption
- type Server
Constants ¶
This section is empty.
Variables ¶
var ( ChainUnaryInterceptor = grpc.ChainUnaryInterceptor ChainStreamInterceptor = grpc.ChainStreamInterceptor UnaryInterceptor = grpc.UnaryInterceptor StreamInterceptor = grpc.StreamInterceptor )
var (
ErrUnknownServiceType = errors.New("unknown service type")
)
Functions ¶
func APIPrefix ¶
func APIPrefix(prefix string) grpc.ServerOption
APIPrefix defines grpc gateway api prefix
func ContextUnaryInterceptor ¶
func GateWayOpts ¶
func GateWayOpts(opts ...runtime.ServeMuxOption) grpc.ServerOption
GateWayOpts provide additional options for api gateway
func Handler ¶
func Handler(pathPrefix string, h http.Handler) grpc.ServerOption
Handler provide ability to define additional HTTP apis beside GRPC Gateway API. All HTTP API with the given prefix will be forwarded to the given handler.
func Listener ¶
func Listener(lis net.Listener) grpc.ServerOption
Listener force server to use the given listener.
func Logger ¶
func Logger(logger logger) grpc.ServerOption
Logger provide alternate logger for server logging
func Middlewares ¶
func Middlewares(mdws ...middleware) grpc.ServerOption
Middlewares apply the given middleware on all HTTP requests
func NotFoundHandler ¶
func NotFoundHandler(h http.Handler) grpc.ServerOption
NotFoundHandler provide alternative not found HTTP handler.
func OnShutdown ¶
func OnShutdown(f func()) grpc.ServerOption
OnShutdown provide custom func to be called before shutting down
func ShutdownTimeout ¶
func ShutdownTimeout(d time.Duration) grpc.ServerOption
ShutdownTimeout define timeout on shutdown.
func TLS ¶
func TLS(certFile, keyFile string) grpc.ServerOption
TLS enable secure mode using tls key & cert file.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...grpc.ServerOption) *Server
func (*Server) DialOpts ¶
func (srv *Server) DialOpts() []grpc.DialOption
DialOpts return dial options for dialling to the server.
func (*Server) ListenAndServe ¶
ListenAndServe start & serving the given services with gracefully shutdown based on context cancelling or system interrupt signals.
func (*Server) RegisterService ¶
func (srv *Server) RegisterService(desc *grpc.ServiceDesc, impl any)
RegisterService implements grpc.ServiceRegistrar