Documentation ¶
Index ¶
- Variables
- func GetAuthCtxKey() string
- func GetAuthorization(token string) string
- func JwtVerify(ctx context.Context) (context.Context, error)
- func SteamClientCircuitBreaker(opts ...CircuitBreakerOption) grpc.StreamClientInterceptor
- func SteamServerCircuitBreaker(opts ...CircuitBreakerOption) grpc.StreamServerInterceptor
- func StreamClientLog(logger *zap.Logger, opts ...grpc_zap.Option) grpc.StreamClientInterceptor
- func StreamClientMetrics() grpc.StreamClientInterceptor
- func StreamClientRetry(opts ...RetryOption) grpc.StreamClientInterceptor
- func StreamClientTracing() grpc.StreamClientInterceptor
- func StreamServerCtxTags() grpc.StreamServerInterceptor
- func StreamServerJwtAuth(opts ...AuthOption) grpc.StreamServerInterceptor
- func StreamServerLog(logger *zap.Logger, opts ...LogOption) grpc.StreamServerInterceptor
- func StreamServerMetrics(opts ...metrics.Option) grpc.StreamServerInterceptor
- func StreamServerRateLimit(opts ...RatelimitOption) grpc.StreamServerInterceptor
- func StreamServerRecovery() grpc.StreamServerInterceptor
- func StreamServerTracing() grpc.StreamServerInterceptor
- func StreamTimeout(d time.Duration) grpc.StreamClientInterceptor
- func UnaryClientCircuitBreaker(opts ...CircuitBreakerOption) grpc.UnaryClientInterceptor
- func UnaryClientLog(logger *zap.Logger, opts ...grpc_zap.Option) grpc.UnaryClientInterceptor
- func UnaryClientMetrics() grpc.UnaryClientInterceptor
- func UnaryClientRetry(opts ...RetryOption) grpc.UnaryClientInterceptor
- func UnaryClientTracing() grpc.UnaryClientInterceptor
- func UnaryServerCircuitBreaker(opts ...CircuitBreakerOption) grpc.UnaryServerInterceptor
- func UnaryServerCtxTags() grpc.UnaryServerInterceptor
- func UnaryServerJwtAuth(opts ...AuthOption) grpc.UnaryServerInterceptor
- func UnaryServerLog(logger *zap.Logger, opts ...LogOption) grpc.UnaryServerInterceptor
- func UnaryServerMetrics(opts ...metrics.Option) grpc.UnaryServerInterceptor
- func UnaryServerRateLimit(opts ...RatelimitOption) grpc.UnaryServerInterceptor
- func UnaryServerRecovery() grpc.UnaryServerInterceptor
- func UnaryServerTracing() grpc.UnaryServerInterceptor
- func UnaryTimeout(d time.Duration) grpc.UnaryClientInterceptor
- type AuthOption
- type AuthOptions
- type CircuitBreakerOption
- type LogOption
- type RatelimitOption
- type RetryOption
Constants ¶
This section is empty.
Variables ¶
var ErrLimitExceed = rl.ErrLimitExceed
ErrLimitExceed is returned when the rate limiter is triggered and the request is rejected due to limit exceeded.
var ErrNotAllowed = circuitbreaker.ErrNotAllowed
ErrNotAllowed error not allowed.
Functions ¶
func SteamClientCircuitBreaker ¶ added in v1.4.0
func SteamClientCircuitBreaker(opts ...CircuitBreakerOption) grpc.StreamClientInterceptor
SteamClientCircuitBreaker client-side stream circuit breaker interceptor
func SteamServerCircuitBreaker ¶ added in v1.4.0
func SteamServerCircuitBreaker(opts ...CircuitBreakerOption) grpc.StreamServerInterceptor
SteamServerCircuitBreaker server-side stream circuit breaker interceptor
func StreamClientLog ¶ added in v1.4.0
StreamClientLog 客户端日志stream拦截器
func StreamClientMetrics ¶
func StreamClientMetrics() grpc.StreamClientInterceptor
StreamClientMetrics 客户端指标stream拦截器
func StreamClientRetry ¶
func StreamClientRetry(opts ...RetryOption) grpc.StreamClientInterceptor
StreamClientRetry 重试stream拦截器
func StreamClientTracing ¶
func StreamClientTracing() grpc.StreamClientInterceptor
StreamClientTracing 客户端链路跟踪stream拦截器
func StreamServerCtxTags ¶
func StreamServerCtxTags() grpc.StreamServerInterceptor
StreamServerCtxTags extractor field stream拦截器
func StreamServerJwtAuth ¶
func StreamServerJwtAuth(opts ...AuthOption) grpc.StreamServerInterceptor
StreamServerJwtAuth jwt鉴权stream拦截器
func StreamServerLog ¶
func StreamServerLog(logger *zap.Logger, opts ...LogOption) grpc.StreamServerInterceptor
StreamServerLog 服务端日志stream拦截器
func StreamServerMetrics ¶
func StreamServerMetrics(opts ...metrics.Option) grpc.StreamServerInterceptor
StreamServerMetrics 服务端指标stream拦截器
func StreamServerRateLimit ¶
func StreamServerRateLimit(opts ...RatelimitOption) grpc.StreamServerInterceptor
StreamServerRateLimit server-side stream circuit breaker interceptor
func StreamServerRecovery ¶
func StreamServerRecovery() grpc.StreamServerInterceptor
StreamServerRecovery recovery stream拦截器
func StreamServerTracing ¶
func StreamServerTracing() grpc.StreamServerInterceptor
StreamServerTracing 服务端链路跟踪stream拦截器
func StreamTimeout ¶
func StreamTimeout(d time.Duration) grpc.StreamClientInterceptor
StreamTimeout 超时stream拦截器
func UnaryClientCircuitBreaker ¶ added in v1.4.0
func UnaryClientCircuitBreaker(opts ...CircuitBreakerOption) grpc.UnaryClientInterceptor
UnaryClientCircuitBreaker client-side unary circuit breaker interceptor
func UnaryClientLog ¶
UnaryClientLog 客户端日志unary拦截器
func UnaryClientMetrics ¶
func UnaryClientMetrics() grpc.UnaryClientInterceptor
UnaryClientMetrics 客户端指标unary拦截器
func UnaryClientRetry ¶
func UnaryClientRetry(opts ...RetryOption) grpc.UnaryClientInterceptor
UnaryClientRetry 重试unary拦截器
func UnaryClientTracing ¶
func UnaryClientTracing() grpc.UnaryClientInterceptor
UnaryClientTracing 客户端链路跟踪unary拦截器
func UnaryServerCircuitBreaker ¶ added in v1.4.0
func UnaryServerCircuitBreaker(opts ...CircuitBreakerOption) grpc.UnaryServerInterceptor
UnaryServerCircuitBreaker server-side unary circuit breaker interceptor
func UnaryServerCtxTags ¶
func UnaryServerCtxTags() grpc.UnaryServerInterceptor
UnaryServerCtxTags extractor field unary拦截器
func UnaryServerJwtAuth ¶
func UnaryServerJwtAuth(opts ...AuthOption) grpc.UnaryServerInterceptor
UnaryServerJwtAuth jwt鉴权unary拦截器
func UnaryServerLog ¶
func UnaryServerLog(logger *zap.Logger, opts ...LogOption) grpc.UnaryServerInterceptor
UnaryServerLog 服务端日志unary拦截器
func UnaryServerMetrics ¶
func UnaryServerMetrics(opts ...metrics.Option) grpc.UnaryServerInterceptor
UnaryServerMetrics 服务端指标unary拦截器
func UnaryServerRateLimit ¶
func UnaryServerRateLimit(opts ...RatelimitOption) grpc.UnaryServerInterceptor
UnaryServerRateLimit server-side unary circuit breaker interceptor
func UnaryServerRecovery ¶
func UnaryServerRecovery() grpc.UnaryServerInterceptor
UnaryServerRecovery recovery unary拦截器
func UnaryServerTracing ¶
func UnaryServerTracing() grpc.UnaryServerInterceptor
UnaryServerTracing 服务端链路跟踪unary拦截器
func UnaryTimeout ¶
func UnaryTimeout(d time.Duration) grpc.UnaryClientInterceptor
UnaryTimeout 超时unary拦截器
Types ¶
type AuthOption ¶
type AuthOption func(*AuthOptions)
AuthOption 设置鉴权字段
func WithAuthClaimsName ¶
func WithAuthClaimsName(claimsName string) AuthOption
WithAuthClaimsName 设置鉴权的信息在ctx的key名称
func WithAuthIgnoreMethods ¶
func WithAuthIgnoreMethods(fullMethodNames ...string) AuthOption
WithAuthIgnoreMethods 忽略鉴权的方法 fullMethodName格式: /packageName.serviceName/methodName, 示例/api.userExample.v1.userExampleService/GetByID
type AuthOptions ¶
type AuthOptions struct {
// contains filtered or unexported fields
}
AuthOptions 鉴权设置
type CircuitBreakerOption ¶ added in v1.4.0
type CircuitBreakerOption func(*circuitBreakerOptions)
CircuitBreakerOption set the circuit breaker circuitBreakerOptions.
func WithGroup ¶ added in v1.4.0
func WithGroup(g *group.Group) CircuitBreakerOption
WithGroup with circuit breaker group. NOTE: implements generics circuitbreaker.CircuitBreaker
type LogOption ¶
type LogOption func(*logOptions)
LogOption 日志设置
func WithLogFields ¶
WithLogFields 添加自定义打印字段
func WithLogIgnoreMethods ¶
WithLogIgnoreMethods 忽略打印的方法 fullMethodName格式: /packageName.serviceName/methodName, 示例/api.userExample.v1.userExampleService/GetByID
type RatelimitOption ¶ added in v1.4.0
type RatelimitOption func(*ratelimitOptions)
RatelimitOption set the rate limits ratelimitOptions.
func WithBucket ¶ added in v1.4.0
func WithBucket(b int) RatelimitOption
WithBucket with bucket size.
func WithCPUQuota ¶ added in v1.4.0
func WithCPUQuota(quota float64) RatelimitOption
WithCPUQuota with real cpu quota(if it can not collect from process correct);
func WithCPUThreshold ¶ added in v1.4.0
func WithCPUThreshold(threshold int64) RatelimitOption
WithCPUThreshold with cpu threshold
func WithWindow ¶ added in v1.4.0
func WithWindow(d time.Duration) RatelimitOption
WithWindow with window size.
type RetryOption ¶
type RetryOption func(*retryOptions)
RetryOption set the retry retryOptions.
func WithRetryErrCodes ¶
func WithRetryErrCodes(errCodes ...codes.Code) RetryOption
WithRetryErrCodes 设置触发重试错误码
func WithRetryInterval ¶
func WithRetryInterval(t time.Duration) RetryOption
WithRetryInterval 设置重试时间间隔,范围1毫秒到10秒