Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // 请求任务标识 TKey = "easy-chat-idempotence-task-id" // 设置rpc调度中rpc请求的标识 DKey = "easy-chat-idempotence-dispatch-key" )
View Source
var ( DefaultIdempotent = new(defaultIdempotent) DefaultIdempotentClient = NewIdempotenceClient(DefaultIdempotent) )
region 定义默认拦截器实现
Functions ¶
func NewIdempotenceClient ¶
func NewIdempotenceClient(idempotent Idempotent) grpc.UnaryClientInterceptor
NewIdempotenceClient 客户端拦截器:把ID塞入请求头
func NewIdempotenceServer ¶
func NewIdempotenceServer(idempotent Idempotent) grpc.UnaryServerInterceptor
NewIdempotenceServer 服务端拦截器: 幂等核心入口
Types ¶
type Idempotent ¶
type Idempotent interface {
// 获取请求的标识
Identify(ctx context.Context, method string) string
// 是否支持幂等性
IsIdempotentMethod(fullMethod string) bool
// 幂等性的验证
TryAcquire(ctx context.Context, id string) (resp interface{}, isAcquire bool, err error)
// 执行之后结果的保存
SaveResp(ctx context.Context, id string, resp interface{}, respErr error) error
}
func NewDefaultIdempotent ¶
func NewDefaultIdempotent(c redis.RedisConf, methods ...string) Idempotent
Click to show internal directories.
Click to hide internal directories.