routing

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Shuffle

func Shuffle(elements []int)

Types

type Lookup

type Lookup func(hashKey string) []int

type RoutingTable

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

RoutingTable makes decisions for where a item should be routed.

func NewRoutingTable

func NewRoutingTable(localNode int, addrs []string, replicationFactor uint) (*RoutingTable, error)

NewRoutingTable returns a new RoutingTable.

func (*RoutingTable) IsLocal

func (t *RoutingTable) IsLocal(metricName string) bool

func (*RoutingTable) Lookup

func (t *RoutingTable) Lookup(item string) []int

Lookup takes a item, hash it and determine what node(s) it should be routed to.

type StaticLookup

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

StaticLookup is used to do lookup for static routes.

func NewStaticLookup

func NewStaticLookup(numOfRoutes int, hasher func(string) uint64) *StaticLookup

NewStaticLookup creates and returns a StaticLookup.

func (*StaticLookup) Lookup

func (l *StaticLookup) Lookup(sourceId string) int

Lookup hashes the SourceId and then returns the index that is in range of the hash.

Jump to

Keyboard shortcuts

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