sharder

package
v0.0.0-...-1215978 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DetShard

type DetShard struct {
	// contains filtered or unexported fields
}

DetShard implements Shard

func (*DetShard) Equals

func (d *DetShard) Equals(other Shard) bool

func (*DetShard) GetAddress

func (d *DetShard) GetAddress() string

GetAddress returns the Shard's address in a usable form

func (*DetShard) GetHashesFor

func (d *DetShard) GetHashesFor(index, n int, seed uint64) []hashShard

GetHashesFor generates a number of hashShards for a given DetShard by repeatedly hashing the seed with itself. The intent is to generate a repeatable pseudo-random sequence.

func (*DetShard) String

func (d *DetShard) String() string

type DeterministicSharder

type DeterministicSharder struct {
	Config config.Config `inject:""`
	Logger logger.Logger `inject:""`
	Peers  peer.Peers    `inject:""`
	// contains filtered or unexported fields
}

func (*DeterministicSharder) MyShard

func (d *DeterministicSharder) MyShard() Shard

func (*DeterministicSharder) Start

func (d *DeterministicSharder) Start() error

func (*DeterministicSharder) WhichShard

func (d *DeterministicSharder) WhichShard(traceID string) Shard

func (*DeterministicSharder) WhichShardHashed

func (d *DeterministicSharder) WhichShardHashed(traceID string) Shard

WhichShardHashed calculates which shard we want by keeping a list of partitions. Each partition has a different hash value and a map from partition to a given shard. We take the traceID and calculate a hash for each partition, using the partition hash as the seed for the trace hash. Whichever one has the highest value is the partition we use, which determines the shard we use. This is O(N) where N is the number of partitions, but because we use an efficient hash, (as opposed to SHA1) it executes in 1 uSec for 50 partitions, so it works out to about the same cost as the legacy sharder.

func (*DeterministicSharder) WhichShardLegacy

func (d *DeterministicSharder) WhichShardLegacy(traceID string) Shard

WhichShardLegacy is the original sharding decider. It uses sha1, which is slow and not well-distributed, and also simply partitions the sharding space into N evenly-divided buckets, which means that on every change in shard count, half of the traces get reassigned (which leads to broken traces). We leave it here to avoid disrupting things and provide a fallback if needed, but the intent is eventually to delete this.

type Shard

type Shard interface {
	Equals(Shard) bool
	// GetAddress returns a string suitable for use in building a URL, eg
	// http://tracing-proxy-1234:8080 or https://10.2.3.4
	GetAddress() string
}

Shard repreesents a single instance of tracing-proxy.

type Sharder

type Sharder interface {
	// MyShard returns the Shard representing this process
	MyShard() Shard
	// WhichShard takes in a trace ID as input and returns the shard responsible
	// for that trace ID
	WhichShard(string) Shard
}

Sharder is for determining which shard should handle a specific trace ID

func GetSharderImplementation

func GetSharderImplementation(c config.Config) Sharder

type SingleServerSharder

type SingleServerSharder struct {
	Logger logger.Logger `inject:""`
}

func (*SingleServerSharder) MyShard

func (s *SingleServerSharder) MyShard() Shard

func (*SingleServerSharder) WhichShard

func (s *SingleServerSharder) WhichShard(traceID string) Shard

type SingleShard

type SingleShard string

SingleShard implements the Shard interface

func (*SingleShard) Equals

func (s *SingleShard) Equals(other Shard) bool

func (*SingleShard) GetAddress

func (s *SingleShard) GetAddress() string

GetAddress will never be used because every shard is my shard

type SortableShardList

type SortableShardList []*DetShard

func (SortableShardList) Equals

func (s SortableShardList) Equals(other SortableShardList) bool

func (SortableShardList) Len

func (s SortableShardList) Len() int

func (SortableShardList) Less

func (s SortableShardList) Less(i, j int) bool

func (SortableShardList) Swap

func (s SortableShardList) Swap(i, j int)

Jump to

Keyboard shortcuts

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