fix default selector

This commit is contained in:
ginuerzh
2022-09-02 21:53:50 +08:00
parent 00f7fa2997
commit 6546f4a905
6 changed files with 70 additions and 10 deletions

View File

@ -0,0 +1,27 @@
package selector
import (
"context"
)
type hashKey struct{}
type Hash struct {
Source string
Value int
}
var (
clientHashKey = &hashKey{}
)
func ContextWithHash(ctx context.Context, hash *Hash) context.Context {
return context.WithValue(ctx, clientHashKey, hash)
}
func HashFromContext(ctx context.Context) *Hash {
if v, _ := ctx.Value(clientHashKey).(*Hash); v != nil {
return v
}
return nil
}