Documentation ¶
Index ¶
- Variables
- func AllPattern() runtime.Pattern
- func DefaultHTTPHandler(mux *runtime.ServeMux) http.Handler
- func PathPattern(path string) runtime.Pattern
- type AnnotatorFunc
- type HTTPHandlerFunc
- type Logger
- type LoggerFunc
- type Option
- func Annotator(annotator AnnotatorFunc) Option
- func ErrorHandler(errorHandler runtime.ProtoErrorHandlerFunc) Option
- func GRPCDialOption(dialOption grpc.DialOption) Option
- func GRPCServerOption(serverOption grpc.ServerOption) Option
- func HTTPHandler(httpHandler HTTPHandlerFunc) Option
- func InterruptSignal(signal os.Signal) Option
- func MuxOption(muxOption runtime.ServeMuxOption) Option
- func PreShutdownDelay(timeout time.Duration) Option
- func Redoc(redoc *RedocOpts) Option
- func RouteOpt(route Route) Option
- func ShutdownFunc(f func()) Option
- func ShutdownTimeout(timeout time.Duration) Option
- func StaticDir(staticDir string) Option
- func StreamInterceptor(streamInterceptor grpc.StreamServerInterceptor) Option
- func UnaryInterceptor(unaryInterceptor grpc.UnaryServerInterceptor) Option
- func WithHTTPServer(server *http.Server) Option
- func WithLogger(logger Logger) Option
- type RedocOpts
- type ReverseProxyFunc
- type Route
- type Service
Constants ¶
This section is empty.
Variables ¶
var InterruptSignals = []os.Signal{ syscall.SIGSTOP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, }
InterruptSignals are the default interrupt signals to catch
Functions ¶
func AllPattern ¶ added in v1.1.0
AllPattern returns a pattern which matches any url
func DefaultHTTPHandler ¶
DefaultHTTPHandler is the default http handler which does nothing
func PathPattern ¶ added in v1.1.0
PathPattern returns a pattern which matches exactly with the path
Types ¶
type AnnotatorFunc ¶
AnnotatorFunc is the annotator function is for injecting meta data from http request into gRPC context
type HTTPHandlerFunc ¶
HTTPHandlerFunc is the http middleware handler function
type Logger ¶ added in v1.1.0
type Logger interface {
Printf(string, ...interface{})
}
Logger is logger interface
type LoggerFunc ¶ added in v1.5.0
type LoggerFunc func(string, ...interface{})
LoggerFunc is a bridge between Logger and any third party logger
func (LoggerFunc) Printf ¶ added in v1.5.0
func (f LoggerFunc) Printf(msg string, args ...interface{})
Printf implements Logger interface
type Option ¶
type Option func(s *Service)
Option is service functional option
See this post about the "functional options" pattern: http://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis
func Annotator ¶
func Annotator(annotator AnnotatorFunc) Option
Annotator returns an Option to append an annotator
func ErrorHandler ¶
func ErrorHandler(errorHandler runtime.ProtoErrorHandlerFunc) Option
ErrorHandler returns an Option to set the errorHandler
func GRPCDialOption ¶ added in v1.4.1
func GRPCDialOption(dialOption grpc.DialOption) Option
GRPCDialOption returns an Option to append a gRPC dial option
func GRPCServerOption ¶ added in v1.4.0
func GRPCServerOption(serverOption grpc.ServerOption) Option
GRPCServerOption returns an Option to append a gRPC server option
func HTTPHandler ¶
func HTTPHandler(httpHandler HTTPHandlerFunc) Option
HTTPHandler returns an Option to set the httpHandler
func InterruptSignal ¶ added in v1.2.0
InterruptSignal returns an Option to append a interrupt signal
func MuxOption ¶ added in v1.5.0
func MuxOption(muxOption runtime.ServeMuxOption) Option
MuxOption returns an Option to append a mux option
func PreShutdownDelay ¶ added in v1.2.0
PreShutdownDelay returns an Option to set the time waiting for running goroutines to finish their jobs before the shutdown starts
func ShutdownFunc ¶ added in v1.2.0
func ShutdownFunc(f func()) Option
ShutdownFunc returns an Option to register a function which will be called when server shutdown
func ShutdownTimeout ¶ added in v1.2.0
ShutdownTimeout returns an Option to set the timeout before the server shutdown abruptly
func StreamInterceptor ¶
func StreamInterceptor(streamInterceptor grpc.StreamServerInterceptor) Option
StreamInterceptor returns an Option to append an streamInterceptor
func UnaryInterceptor ¶
func UnaryInterceptor(unaryInterceptor grpc.UnaryServerInterceptor) Option
UnaryInterceptor returns an Option to append an unaryInterceptor
func WithHTTPServer ¶ added in v1.4.0
WithHTTPServer returns an Option to set the http server, note that the Addr and Handler will be reset in startGRPCGateway(), so you are not able to specify them
func WithLogger ¶ added in v1.5.0
WithLogger uses the provided logger
type RedocOpts ¶
type RedocOpts struct { // Route is the route in http server, DO NOT include / at the beginning Route string // SpecURLs are the urls to find the spec for, format: name -> url SpecURLs map[string]string // RedocURL is the js that generates the redoc site, defaults to: https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js RedocURL string // Title is the page title, default to: API documentation Title string // Up is whether to boot up the redoc endpoints Up bool }
RedocOpts is configures for redoc
type ReverseProxyFunc ¶
type ReverseProxyFunc func(ctx context.Context, mux *runtime.ServeMux, grpcHostAndPort string, opts []grpc.DialOption) error
ReverseProxyFunc is the callback that the caller should implement to steps to reverse-proxy the HTTP/1 requests to gRPC
type Route ¶ added in v1.1.0
type Route struct { Method string Pattern runtime.Pattern Handler runtime.HandlerFunc }
Route represents the route for mux
type Service ¶
type Service struct { GRPCServer *grpc.Server HTTPServer *http.Server // contains filtered or unexported fields }
Service represents the microservice