Documentation
¶
Index ¶
- func ActiveInstances(i iter.Iterator[ring.InstanceDesc]) iter.Iterator[ring.InstanceDesc]
- func FilterInstances(i iter.Iterator[ring.InstanceDesc], filter func(x *ring.InstanceDesc) bool) iter.Iterator[ring.InstanceDesc]
- func InstanceSet(i iter.Iterator[ring.InstanceDesc]) iter.Iterator[ring.InstanceDesc]
- type Key
- type Placement
- type Policy
- type ShardMapping
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveInstances ¶ added in v1.10.0
func ActiveInstances(i iter.Iterator[ring.InstanceDesc]) iter.Iterator[ring.InstanceDesc]
ActiveInstances returns an iterator that filters out inactive instances. Note that active state does not mean that the instance is healthy.
func FilterInstances ¶ added in v1.10.0
func FilterInstances( i iter.Iterator[ring.InstanceDesc], filter func(x *ring.InstanceDesc) bool, ) iter.Iterator[ring.InstanceDesc]
FilterInstances returns an iterator that filters out instances on which the filter function returns true.
func InstanceSet ¶ added in v1.10.0
func InstanceSet(i iter.Iterator[ring.InstanceDesc]) iter.Iterator[ring.InstanceDesc]
Types ¶
type Policy ¶ added in v1.10.0
type Policy struct { // TenantShards returns the number of shards // available to the tenant. TenantShards int // DatasetShards returns the number of shards // available to the dataset from the tenant shards. DatasetShards int // PickShard returns the shard index // for a given key from n total. PickShard func(n int) int }
Policy is a placement policy of a given key.
type ShardMapping ¶ added in v1.10.0
type ShardMapping struct { Instances iter.Iterator[ring.InstanceDesc] Shard uint32 }
ShardMapping represents the placement of a given key.
Each key is mapped to one of the shards, based on the placement strategy. In turn, each shard is associated with an instance.
ShardMapping provides a number of instances that can host the key. It is assumed, that the caller will use the first one by default, and will try the rest in case of failure. This is done to avoid excessive data distribution in case of temporary unavailability of the instances: first, we try the instance that the key is mapped to, then we try the instances that host the dataset, then instances that host the tenant. Finally, we try any instances.
Note that the instances are not guaranteed to be unique. It's also not guaranteed that the instances are available. Use ActiveInstances wrapper if you need to filter out inactive instances and duplicates.