Documentation ¶
Index ¶
- func CheckAvailable(fc FeatureChecker) grpc.UnaryServerInterceptor
- func ForwardToLeader[T any](fc ForwardChecker[T]) grpc.UnaryServerInterceptor
- func FromGRPCError(errIn error) error
- func Logger(allowList []string, limiter *rate.Limiter) grpc.UnaryServerInterceptor
- func NormalizeError() grpc.UnaryServerInterceptor
- func ToGRPCError(errIn error) error
- type FeatureChecker
- type ForwardChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAvailable ¶
func CheckAvailable(fc FeatureChecker) grpc.UnaryServerInterceptor
CheckAvailable is a gRPC middleware that checks whether a method is ready to serve.
func ForwardToLeader ¶
func ForwardToLeader[T any](fc ForwardChecker[T]) grpc.UnaryServerInterceptor
ForwardToLeader is a gRPC middleware that forwards the request to the leader if the current node is not the leader.
func FromGRPCError ¶
FromGRPCError converts a gRPC error to a normalized error.
func Logger ¶
func Logger(allowList []string, limiter *rate.Limiter) grpc.UnaryServerInterceptor
Logger is a gRPC middleware that logs the request and response. allowList is a list of methods that will be logged. limiter is used to limit the log rate.
func NormalizeError ¶
func NormalizeError() grpc.UnaryServerInterceptor
NormalizeError is a gRPC middleware that normalizes the error.
func ToGRPCError ¶
ToGRPCError converts an error to a gRPC error.
Types ¶
type FeatureChecker ¶
FeatureChecker defines an interface that checks whether a feature is available or under degradation.
type ForwardChecker ¶
type ForwardChecker[T any] interface { // LeaderOnly returns whether the request is only allowed to handle by the leader. LeaderOnly(method string) bool // IsLeader returns whether the current node is the leader. IsLeader() bool // LeaderClient returns the leader client. If there is no leader, it should return // nil and errors.ErrMasterNoLeader. LeaderClient() (T, error) }
ForwardChecker is used for checking whether a request should be forwarded or not.