chtest

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package chtest provides some helper hash-functions for use with the parent consistenthash package (and galaxycache) to provide particular owners for specific keys.

This package cannot be imported outside of tests. If testing.Testing returns false, it will panic in init() unless compiled with the `testing_binary_chtest_can_panic_at_any_time` build tag (intended to be used for tests that require running a separate binary (e.g. integration/interop tests)).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FallthroughKey

func FallthroughKey(origOwner, fallthroughOwner string) string

FallthroughKey constructs a key that is owned by original owner, and if origOwner is removed from the hash-ring, falls through to fallthroughOwner. ... as long as both owners were included in the call to NewMapArgs

func SingleOwnerKey

func SingleOwnerKey(owner string) string

SingleOwnerKey returns a key that is guaranteed to map to that owner (as long as that owner was included in the call to NewMapArgs

Types

type Args

type Args struct {
	Owners []string
	// Map from a key to a set of replicas to the set of owners to map this key into for its sequential replicas (GetReplicated)
	// if the value is nil, then one hash for each owner is picked sequentially
	RegisterKeys map[string][]string
}

Args is an argument struct to NewMapArgs

type MapArgs

type MapArgs struct {
	NSegsPerKey int
	HashFunc    func([]byte) uint32
}

MapArgs provides the values that should be passed through to consistenthash.NewMap (possibly indirectly)

func NewMapArgs

func NewMapArgs(args Args) MapArgs

NewMapArgs creates a consistenthash.Map that uses a constructed "hash function" that is engineered to pick the correct, the integer it computes required value of segsPerKey to make every ordering of the entries in owners appear in the hashring.

func (*MapArgs) NewMap

func (m *MapArgs) NewMap() *consistenthash.Map

NewMap creates a new consistenthash.Map with the args from the receiver. It does _not_ populate the hashring.

Jump to

Keyboard shortcuts

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