midwares

package
v0.0.0-...-1382dd4 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 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() grpc.UnaryServerInterceptor

func PanicRecoverStream

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

Jump to

Keyboard shortcuts

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