idservice

package
v0.0.0-...-6206b6d Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextBallot

func NextBallot(ballot int, id ID) int

NextBallot generates next ballot number given current ballot bumber and node idservice

Types

type Ballot

type Ballot uint64

Ballot is ballot number type combines 32 bits of natual number and 32 bits of node idservice into uint64

func NewBallot

func NewBallot(n int, id ID) Ballot

NewBallot generates ballot number in format <n, zone, node>

func NewBallotFromString

func NewBallotFromString(b string) Ballot

func (Ballot) ID

func (b Ballot) ID() ID

NodeId return node idservice as last 32 bits of ballot

func (Ballot) N

func (b Ballot) N() int

N returns first 32 bit of ballot

func (*Ballot) Next

func (b *Ballot) Next(id ID)

Next generates the next ballot number given node idservice

func (Ballot) String

func (b Ballot) String() string

type ID

type ID uint32

NodeId represents a generic identifier in format of Zone.Node

func LeaderID

func LeaderID(ballot int) ID

LeaderID return the node idservice from ballot number

func NewID

func NewID(zone, node int) ID

NewID returns a new NodeId type given two int number of zone and node

func NewIDFromString

func NewIDFromString(idstr string) ID

func (ID) Node

func (i ID) Node() int

Node returns Node NodeId component

func (ID) String

func (i ID) String() string

func (ID) Zone

func (i ID) Zone() int

Zone returns Zone NodeId component

type IDs

type IDs []ID

func (IDs) Len

func (a IDs) Len() int

func (IDs) Less

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

func (IDs) Swap

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

type Policy

type Policy interface {
	Hit(id ID) ID
}

Policy defines a trigger for data access patterns, that can be used in data migration protocols

func NewPolicy

func NewPolicy(policy string, threshold float64) Policy

NewPolicy returns the policy by policy name from config

Jump to

Keyboard shortcuts

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