chash

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSimpleATSConsistentHashReplicas = 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type ATSConsistentHash

type ATSConsistentHash interface {
	Insert(node *ATSConsistentHashNode, weight float64) error
	String() string
	// Lookup returns the found node, its map iterator, and whether the lookup wrapped
	Lookup(name string) (OrderedMapUint64NodeIterator, bool, error)
	LookupHash(hashVal uint64) (OrderedMapUint64NodeIterator, bool)
	LookupIter(OrderedMapUint64NodeIterator) (OrderedMapUint64NodeIterator, bool)
	First() OrderedMapUint64NodeIterator // debug
}

func NewSimpleATSConsistentHash

func NewSimpleATSConsistentHash(replicas int) ATSConsistentHash

type ATSConsistentHashNode

type ATSConsistentHashNode struct {
	Available bool
	Name      string
	ProxyURL  *url.URL
	Transport *http.Transport
	// pRecord fields (ParentSelection.h)
	Hostname  string
	Port      int
	FailedAt  time.Time
	FailCount int
	UpAt      int
	Scheme    string
	Index     int
	Weight    float64
}

ATSConsistentHashNode is an ATS ParentRecord

func (ATSConsistentHashNode) String

func (n ATSConsistentHashNode) String() string

type OrderedMapUint64Node

type OrderedMapUint64Node interface {
	Insert(key uint64, val *ATSConsistentHashNode)
	String() string
	InsertBulk(keys []uint64, vals []*ATSConsistentHashNode) error
	First() OrderedMapUint64NodeIterator
	Last() OrderedMapUint64NodeIterator
	At(index int) (uint64, *ATSConsistentHashNode)
	LowerBound(val uint64) OrderedMapUint64NodeIterator
}

func NewSimpleOrderedMapUint64Node

func NewSimpleOrderedMapUint64Node() OrderedMapUint64Node

type OrderedMapUint64NodeIterator

type OrderedMapUint64NodeIterator interface {
	Val() *ATSConsistentHashNode
	Key() uint64
	Next() OrderedMapUint64NodeIterator
	NextWrap() OrderedMapUint64NodeIterator
	Index() int
}

type SimpleATSConsistentHash

type SimpleATSConsistentHash struct {
	Replicas int
	NodeMap  OrderedMapUint64Node
}

func (*SimpleATSConsistentHash) First

func (*SimpleATSConsistentHash) Insert

func (*SimpleATSConsistentHash) Lookup

Lookup returns the found node, its map iterator, and whether the lookup wrapped

func (*SimpleATSConsistentHash) LookupHash

func (*SimpleATSConsistentHash) LookupIter

func (*SimpleATSConsistentHash) String

func (h *SimpleATSConsistentHash) String() string

type SimpleOrderedMapUInt64Node

type SimpleOrderedMapUInt64Node struct {
	M map[uint64]*ATSConsistentHashNode
	O []uint64
}

func (*SimpleOrderedMapUInt64Node) At

func (*SimpleOrderedMapUInt64Node) First

First returns the iterator to the first element in the map. Returns nil if the map is empty

func (*SimpleOrderedMapUInt64Node) Insert

func (*SimpleOrderedMapUInt64Node) InsertBulk

func (m *SimpleOrderedMapUInt64Node) InsertBulk(keys []uint64, vals []*ATSConsistentHashNode) error

func (*SimpleOrderedMapUInt64Node) Last

Last returns the iterator to the last element in the map. Returns nil if the map is empty

func (*SimpleOrderedMapUInt64Node) LowerBound

func (*SimpleOrderedMapUInt64Node) String

func (m *SimpleOrderedMapUInt64Node) String() string

type SimpleOrderedMapUint64NodeIterator

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

func (*SimpleOrderedMapUint64NodeIterator) Index

func (*SimpleOrderedMapUint64NodeIterator) Key

func (*SimpleOrderedMapUint64NodeIterator) Next

func (*SimpleOrderedMapUint64NodeIterator) NextWrap

func (*SimpleOrderedMapUint64NodeIterator) Prev

func (*SimpleOrderedMapUint64NodeIterator) Val

type SortableUint64

type SortableUint64 []uint64

func (SortableUint64) Len

func (a SortableUint64) Len() int

func (SortableUint64) Less

func (a SortableUint64) Less(i, j int) bool

func (SortableUint64) Swap

func (a SortableUint64) Swap(i, j int)

Jump to

Keyboard shortcuts

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