fix default selector
This commit is contained in:
27
internal/util/selector/key.go
Normal file
27
internal/util/selector/key.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user