midwares

package
v0.0.0-...-265ede9 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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 GetUserFromCtx

func GetUserFromCtx(ctx context.Context) *models.User

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

type RecoveryHandlerFuncContext func(ctx context.Context, p interface{}) (err error)

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()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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