Documentation ¶
Index ¶
- Variables
- func AllPattern() runtime.Pattern
- func DefaultAnnotator(ctx context.Context, req *http.Request) metadata.MD
- func DefaultHTTPHandler(s *Service) http.Handler
- func InitJaeger(service, samplingServerURL, localAgentHost string, debug bool) (io.Closer, error)
- func PathPattern(path string) runtime.Pattern
- func RequestID(req *http.Request) string
- 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 ¶
AllPattern returns a pattern which matches any url
func DefaultAnnotator ¶
DefaultAnnotator passes span info into gRPC context
func DefaultHTTPHandler ¶
DefaultHTTPHandler is the default http handler which will initiate the tracing span and set the http response header with X-Request-Id
func InitJaeger ¶
InitJaeger is the helper to initiate an instance of Jaeger Tracer as global tracer, if you need to customize your tracer, you can do it yourself instead of calling this function
func PathPattern ¶
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 LoggerFunc ¶ added in v1.2.0
type LoggerFunc func(string, ...interface{})
LoggerFunc is a bridge between Logger and any third party logger
func (LoggerFunc) Printf ¶ added in v1.2.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 ¶
func GRPCDialOption(dialOption grpc.DialOption) Option
GRPCDialOption returns an Option to append a gRPC dial option
func GRPCServerOption ¶
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 ¶
InterruptSignal returns an Option to append a interrupt signal
func MuxOption ¶ added in v1.1.0
func MuxOption(muxOption runtime.ServeMuxOption) Option
MuxOption returns an Option to append a mux option
func PreShutdownDelay ¶
PreShutdownDelay returns an Option to set the time waiting for running goroutines to finish their jobs before the shutdown starts
func ShutdownFunc ¶
func ShutdownFunc(f func()) Option
ShutdownFunc returns an Option to register a function which will be called when server shutdown
func ShutdownTimeout ¶
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 ¶
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.2.0
WithLogger uses the provided logger
type RedocOpts ¶
type RedocOpts struct { // Route - the route in http server, DO NOT include / at the beginning Route string // SpecURLs - the urls to find the spec for, format: name -> url SpecURLs map[string]string // RedocURL - the js that generates the redoc site, defaults to: https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js RedocURL string // Title - the page title, default to: API documentation Title string // Up - 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 ¶
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
func (*Service) InitSpan ¶ added in v1.2.0
InitSpan initiates the tracing span and set the http response header with X-Request-Id