Documentation ¶
Index ¶
- type Logger
- type MethodDesc
- type Option
- func AddEvery(token string, d time.Duration, b int) Option
- func AddLimiter(token string, limiter *rate.Limiter) Option
- func DisableMetric() Option
- func EnableMetric(registerer prometheus.Registerer) Option
- func WithCounterVec(counter *prometheus.CounterVec) Option
- func WithGlobalEvery(d time.Duration, b int) Option
- func WithGlobalLimiter(limiter *rate.Limiter) Option
- func WithGrpcLogger(logger grpclog.LoggerV2) Option
- func WithLogger(logger Logger) Option
- func WithMaxWait(maxWait time.Duration) Option
- type Server
- type ServiceDesc
- type ServiceRegistrar
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface { // Info logs to INFO log. Arguments are handled in the manner of fmt.Print. Info(ctx context.Context, args ...interface{}) // Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println. Infoln(ctx context.Context, args ...interface{}) // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. Infof(ctx context.Context, format string, args ...interface{}) // Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print. Warning(ctx context.Context, args ...interface{}) // Warningln logs to WARNING log. Arguments are handled in the manner of fmt.Println. Warningln(ctx context.Context, args ...interface{}) // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. Warningf(ctx context.Context, format string, args ...interface{}) // Error logs to ERROR log. Arguments are handled in the manner of fmt.Print. Error(ctx context.Context, args ...interface{}) // Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println. Errorln(ctx context.Context, args ...interface{}) // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. Errorf(ctx context.Context, format string, args ...interface{}) // Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. Fatal(ctx context.Context, args ...interface{}) // Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. Fatalln(ctx context.Context, args ...interface{}) // Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. // gRPC ensures that all Fatal logs will exit with os.Exit(1). // Implementations may also call os.Exit() with a non-zero exit code. Fatalf(ctx context.Context, format string, args ...interface{}) // V reports whether verbosity level l is at least the requested verbose level. V(l int) bool }
LoggerV2 does underlying logging work for grpclog.
func WrapGrpcLogger ¶
type MethodDesc ¶
type MethodDesc struct { MethodName string ComplexityHandler func(srv interface{}, ctx context.Context, req interface{}) map[string]int }
MethodDesc represents an RPC service's method specification.
type Option ¶
type Option func(*Server)
func AddEvery ¶
AddEvery Every d allow one request with 1 complexity Every request's complexity should less b
func DisableMetric ¶ added in v0.0.2
func DisableMetric() Option
func EnableMetric ¶ added in v0.0.2
func EnableMetric(registerer prometheus.Registerer) Option
func WithCounterVec ¶ added in v0.0.2
func WithCounterVec(counter *prometheus.CounterVec) Option
func WithGlobalEvery ¶
WithGlobalEvery refer: AddEvery
func WithGlobalLimiter ¶
WithGlobalLimiter The default limiter for any unknown token
func WithGrpcLogger ¶
func WithLogger ¶
func WithMaxWait ¶
WithMaxWait The max duration to wait, when qps reached the upper limit.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) RegisterService ¶
func (s *Server) RegisterService(sd *ServiceDesc, ss interface{})
func (*Server) UnaryServerInterceptor ¶
func (s *Server) UnaryServerInterceptor() grpc.UnaryServerInterceptor
type ServiceDesc ¶
type ServiceDesc struct { ServiceName string // The pointer to the service interface. Used to check whether the user // provided implementation satisfies the interface requirements. HandlerType interface{} Methods []MethodDesc Metadata interface{} }
ServiceDesc represents an RPC service's specification.
type ServiceRegistrar ¶
type ServiceRegistrar interface {
RegisterService(*ServiceDesc, interface{})
}
Click to show internal directories.
Click to hide internal directories.