Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( DefHashFunc = FNV64a FNV64a = fnv.New64a FNV64 = fnv.New64 CRCISO = func() hash.Hash64 { return crc64.New(crc64.MakeTable(crc64.ISO)) } CRCECMA = func() hash.Hash64 { return crc64.New(crc64.MakeTable(crc64.ECMA)) } MapHash = func() hash.Hash64 { return new(maphash.Hash) } )
The following are the hash.Hash64 constructors provided by various Go stdlib packages
var DefShardCount = nextPrime(uint64(runtime.NumCPU() * 7))
DefShardCount is the heuristically determined default shard count. It will vary by machine taking into consideration factors such as the number of cores present
Functions ¶
This section is empty.
Types ¶
type GroupOptions ¶
type GroupOptions interface {
// contains filtered or unexported methods
}
GroupOptions represents an option that can be provided to the ShardGroup constructor
type ShardedGroup ¶
type ShardedGroup struct {
// contains filtered or unexported fields
}
ShardedGroup is a sharded singleflight Group. See singleflight.Group
func NewShardedGroup ¶
func NewShardedGroup(opts ...GroupOptions) *ShardedGroup
NewShardedGroup is the sharded singleflight Group contstructor. Any provided options, which may be absent, will be applied.
func (*ShardedGroup) Do ¶
func (sg *ShardedGroup) Do(key string, fn func() (interface{}, error)) (v interface{}, err error, shared bool)
Do maps the key to a shard and runs the singleflight shard's Do. See singleflight.Do
func (*ShardedGroup) DoChan ¶
func (sg *ShardedGroup) DoChan(key string, fn func() (interface{}, error)) <-chan singleflight.Result
DoChan maps the key to a shard and runs the singleflight shard's DoChan. See singleflight.DoChan
func (*ShardedGroup) Forget ¶
func (sg *ShardedGroup) Forget(key string)
Forget maps the key to a shard and runs the singleflight shard's Forget. See singleflight.Forget
type WithHashFunc ¶
type WithHashFunc NewHash
WithHashFunc is an option to override the default hash.Hash64 constructor used by a ShardGroup
type WithShardCount ¶
type WithShardCount uint64
WithShardCount is an option to override the default shard count with an explicit count