refactor: 将 WithSticky 重命名为 StickyCtx,避免与 pool Option 的 With* 前缀冲突
This commit is contained in:
@@ -7,11 +7,11 @@ import (
|
||||
|
||||
type stickyKey struct{} // 用户提供的字符串 key,acquire 时 hash 到 worker 下标
|
||||
|
||||
// WithSticky 将粘性键写入 ctx,相同 key 始终路由到同一 worker 进程。
|
||||
// StickyCtx 将粘性键写入 ctx,相同 key 始终路由到同一 worker 进程。
|
||||
//
|
||||
// ctx = gobridge.WithSticky(ctx, "user-42")
|
||||
// ctx = gobridge.StickyCtx(ctx, "user-42")
|
||||
// gobridge.Invoke(ctx, pool, "method", ...) // 同 key 始终走同一进程
|
||||
func WithSticky(ctx context.Context, key string) context.Context {
|
||||
func StickyCtx(ctx context.Context, key string) context.Context {
|
||||
return context.WithValue(ctx, stickyKey{}, key)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user