refactor: 将 WithSticky 重命名为 StickyCtx,避免与 pool Option 的 With* 前缀冲突

This commit is contained in:
2026-05-08 15:21:59 +08:00
parent a3cf983b39
commit e6a61cc1ee
3 changed files with 11 additions and 11 deletions

View File

@@ -7,11 +7,11 @@ import (
type stickyKey struct{} // 用户提供的字符串 keyacquire 时 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)
}