testutil

package
v0.0.0-...-9649366 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

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

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

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