complexity

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2021 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

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

func WrapGrpcLogger(logger grpclog.LoggerV2) Logger

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

func AddEvery(token string, d time.Duration, b int) Option

AddEvery Every d allow one request with 1 complexity Every request's complexity should less b

func AddLimiter

func AddLimiter(token string, limiter *rate.Limiter) Option

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

func WithGlobalEvery(d time.Duration, b int) Option

WithGlobalEvery refer: AddEvery

func WithGlobalLimiter

func WithGlobalLimiter(limiter *rate.Limiter) Option

WithGlobalLimiter The default limiter for any unknown token

func WithGrpcLogger

func WithGrpcLogger(logger grpclog.LoggerV2) Option

func WithLogger

func WithLogger(logger Logger) Option

func WithMaxWait

func WithMaxWait(maxWait time.Duration) Option

WithMaxWait The max duration to wait, when qps reached the upper limit.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Server, error)

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{})
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL