placement

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveInstances added in v1.10.0

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

Types

type Key

type Key struct {
	TenantID    string
	DatasetName string

	Tenant      uint64
	Dataset     uint64
	Fingerprint uint64
}

type Placement

type Placement interface {
	Policy(Key) Policy
}

Placement is a strategy to distribute keys over shards.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL