testutil

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 4 Imported by: 5 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// SelfID is the string used to represent the ID of the origin node.
	SelfID = "self"
)

Variables

This section is empty.

Functions

func MustNewTopologyMap

func MustNewTopologyMap(
	replicas int,
	assignment map[string][]shard.Shard,
) topology.Map

MustNewTopologyMap returns a new topology.Map with provided parameters. It's a utility method to make tests easier to write.

func NewStateSnapshot added in v0.4.4

func NewStateSnapshot(numMajorityReplicas int, hostShardStates HostShardStates) *topology.StateSnapshot

NewStateSnapshot creates a new initial topology state snapshot using HostShardStates as input.

func Shards

func Shards(ids []uint32, s shard.State) []shard.Shard

Shards returns a slice of shards with provided ids and state `s`.

func ShardsRange

func ShardsRange(from, to uint32, s shard.State) []shard.Shard

ShardsRange returns a slice of shards for all ids between [from, to], with shard state `s`.

func Uint32Range

func Uint32Range(from, to uint32) []uint32

Uint32Range returns a slice of all values between [from, to].

Types

type HostShardStates added in v0.4.4

type HostShardStates map[string][]shard.Shard

HostShardStates is a human-readable way of describing an initial state topology on a host-by-host basis.

type TopologyView

type TopologyView struct {
	HashFn     sharding.HashFn
	Replicas   int
	Assignment map[string][]shard.Shard
}

TopologyView represents a snaphshot view of a topology.Map.

func NewTopologyView

func NewTopologyView(
	replicas int,
	assignment map[string][]shard.Shard,
) TopologyView

NewTopologyView returns a new TopologyView with provided parameters. It's a utility method to make tests easier to write.

func (TopologyView) Map

func (v TopologyView) Map() (topology.Map, error)

Map returns the topology.Map corresponding to a TopologyView.

Jump to

Keyboard shortcuts

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