interceptor

package
v0.0.0-...-10b6da0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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 ContextWithIdempotentID

func ContextWithIdempotentID(ctx context.Context) context.Context

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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