slicer

package
v0.0.0-...-b88123c Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(key string) int64

Types

type Assigner

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

Assigner maintains hosts and their assignments.

func (*Assigner) AddHost

func (s *Assigner) AddHost(name string, liveKeys []string) (err error)

func (*Assigner) Assignments

func (s *Assigner) Assignments() map[string][]Range

func (*Assigner) Host

func (s *Assigner) Host(key string) string

Host provides a host's identifier for a given key.

type HostAssignments

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

HostAssignments stores hosts and their corresponding ranges of hash values. Each host gets a set of key ranges that it owns. This struct handles building, validating and querying those slice ranges.

func NewFromSerialized

func NewFromSerialized(r io.Reader) (*HostAssignments, error)

func NewHostAssignments

func NewHostAssignments(assignments map[string][]Range) (*HostAssignments, error)

NewHostAssignments will create a new HostAssignments from a complete set of assignments. If the assignment ranges are not complete, or are overlapping, this function will return an error.

func (*HostAssignments) Assignments

func (hm *HostAssignments) Assignments() map[string][]Range

Assignments returns a full copy of the internal assignments.

func (*HostAssignments) GetHost

func (hm *HostAssignments) GetHost(key string) string

GetHost get a host's identifier for a given key.

func (*HostAssignments) NewAssignments

func (hm *HostAssignments) NewAssignments(assignments map[string][]Range) error

NewAssignments takes a new set of assignments. If the assignment ranges are not complete, or are overlapping, this function will return an error.

func (*HostAssignments) Serialize

func (hm *HostAssignments) Serialize(w io.Writer) error

type Range

type Range struct {
	Start int64
	End   int64
}

type RangeAndHost

type RangeAndHost struct {
	Host  string
	Range Range
}

Jump to

Keyboard shortcuts

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