Documentation ¶
Index ¶
- Constants
- func AuthChecker() grpc.UnaryServerInterceptor
- func AuthCheckerStream() grpc.StreamServerInterceptor
- func BasicLogger() grpc.UnaryServerInterceptor
- func BasicLoggerStream() grpc.StreamServerInterceptor
- func GetUserFromCtx(ctx context.Context) *models.User
- func PanicRecover(opts ...RecoverOption) grpc.UnaryServerInterceptor
- func PanicRecoverStream(opts ...RecoverOption) grpc.StreamServerInterceptor
- func RateLimiter(mode uint) grpc.UnaryServerInterceptor
- type NeedAuthChecker
- type RecoverOption
- type RecoveryHandlerFunc
- type RecoveryHandlerFuncContext
- type WrappedServerStream
Constants ¶
const ( CAPACITY = 1000 FILL_INTERVAL = 10 * time.Second / CAPACITY WAIT_TIME = 100 * time.Millisecond CHANNEL_LIMIT uint = iota TOKENBUCKET_LIMIT )
Variables ¶
This section is empty.
Functions ¶
func AuthChecker ¶
func AuthChecker() grpc.UnaryServerInterceptor
func AuthCheckerStream ¶
func AuthCheckerStream() grpc.StreamServerInterceptor
func BasicLogger ¶
func BasicLogger() grpc.UnaryServerInterceptor
func BasicLoggerStream ¶
func BasicLoggerStream() grpc.StreamServerInterceptor
func PanicRecover ¶
func PanicRecover(opts ...RecoverOption) grpc.UnaryServerInterceptor
PanicRecover returns a new unary server interceptor for panic recovery.
func PanicRecoverStream ¶
func PanicRecoverStream(opts ...RecoverOption) grpc.StreamServerInterceptor
PanicRecoverStream returns a new streaming server interceptor for panic recovery.
func RateLimiter ¶
func RateLimiter(mode uint) grpc.UnaryServerInterceptor
Types ¶
type NeedAuthChecker ¶
type NeedAuthChecker interface {
NeedAuth() bool
}
NeedAuthChecker All servers registered with this interceptor MUST implement this interface
type RecoverOption ¶
type RecoverOption func(*options)
func WithRecoveryHandler ¶
func WithRecoveryHandler(f RecoveryHandlerFunc) RecoverOption
WithRecoveryHandler customizes the function for recovering from a panic.
func WithRecoveryHandlerContext ¶
func WithRecoveryHandlerContext(f RecoveryHandlerFuncContext) RecoverOption
WithRecoveryHandlerContext customizes the function for recovering from a panic.
type RecoveryHandlerFunc ¶
type RecoveryHandlerFunc func(p interface{}) (err error)
RecoveryHandlerFunc is a function that recovers from the panic `p` by returning an `error`.
type RecoveryHandlerFuncContext ¶
RecoveryHandlerFuncContext is a function that recovers from the panic `p` by returning an `error`. The context can be used to extract request scoped metadata and context values.
type WrappedServerStream ¶
type WrappedServerStream struct { grpc.ServerStream // WrappedContext is the wrapper's own Context. You can assign it. WrappedContext context.Context }
WrappedServerStream is a thin wrapper around grpc.ServerStream that allows modifying context.
func WrapServerStream ¶
func WrapServerStream(stream grpc.ServerStream) *WrappedServerStream
WrapServerStream returns a ServerStream that has the ability to overwrite context.
func (*WrappedServerStream) Context ¶
func (w *WrappedServerStream) Context() context.Context
Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()