Documentation ¶
Index ¶
- Constants
- Variables
- func AssertWithin(t *testing.T, f func() (string, bool), d time.Duration)
- func BetweenIE(needle, fromInc, toExc []byte) (result bool)
- func BetweenII(needle, fromInc, toInc []byte) (result bool)
- func DecodeBigInt(b []byte) (result *big.Int)
- func DecodeFloat64(b []byte) (result float64, err error)
- func DecodeInt64(b []byte) (result int64, err error)
- func EncodeBigInt(i *big.Int) []byte
- func EncodeFloat64(f float64) []byte
- func EncodeInt64(i int64) []byte
- func HexEncode(b []byte) (result string)
- func Max(i ...int) (result int)
- func Max64(i ...int64) (result int64)
- func Min(i ...int) (result int)
- func Min64(i ...int64) (result int64)
- func MustDecodeFloat64(b []byte) (result float64)
- func MustDecodeInt64(b []byte) (result int64)
- func MustParseFloat64(s string) (result float64)
- type Conf
- type ConfItem
- type DHashDescription
- type Index
- type Item
- type Range
- type Remote
- func (self Remote) Call(service string, args, reply interface{}) error
- func (self Remote) Clone() (result Remote)
- func (self Remote) Equal(other Remote) bool
- func (self Remote) Go(service string, args, reply interface{}) *rpc.Call
- func (self Remote) Less(other Remote) bool
- func (self Remote) String() string
- type Remotes
- type Ring
- func (self *Ring) Add(r Remote)
- func (self *Ring) AddChangeListener(f RingChangeListener)
- func (self *Ring) Clean(predecessor, successor Remote)
- func (self *Ring) Clone() *Ring
- func (self *Ring) Describe() string
- func (self *Ring) Equal(other *Ring) bool
- func (self *Ring) GetSlot() []byte
- func (self *Ring) Hash() []byte
- func (self *Ring) Nodes() Remotes
- func (self *Ring) Predecessor(r Remote) Remote
- func (self *Ring) Random() Remote
- func (self *Ring) Redundancy() int
- func (self *Ring) Remotes(pos []byte) (before, at, after *Remote)
- func (self *Ring) Remove(remote Remote)
- func (self *Ring) SetNodes(nodes Remotes)
- func (self *Ring) Size() int
- func (self *Ring) Successor(r Remote) Remote
- func (self *Ring) Validate()
- type RingChangeListener
- type Switchboard
- type TimeLock
Constants ¶
const ( Redundancy = 3 PingInterval = time.Second )
Variables ¶
var Switch = newSwitchboard()
Switch is the default Switchboard.
Functions ¶
func AssertWithin ¶
AssertWithin asserts that the given func returns a true bool within d, or it fires an error through t.
func BetweenIE ¶
BetweenIE returns whether needle is between fromInc, inclusive and toExc, exclusive.
func DecodeBigInt ¶
func DecodeFloat64 ¶
func DecodeInt64 ¶
func EncodeBigInt ¶
func EncodeFloat64 ¶
func EncodeInt64 ¶
func HexEncode ¶
HexEncode will encode the given bytes to a string, and pad it with 0 until it is at least twice the length of b.
func MustDecodeFloat64 ¶
func MustDecodeInt64 ¶
func MustParseFloat64 ¶
Types ¶
type DHashDescription ¶
type DHashDescription struct { Addr string Pos []byte LastReroute time.Time LastSync time.Time LastMigrate time.Time Timer time.Time OwnedEntries int HeldEntries int Load float64 Nodes Remotes }
DHashDescription contains a description of a dhash node.
func (DHashDescription) Describe ¶
func (self DHashDescription) Describe() string
Describe will return a humanly readable string description of the dhash node.
type Item ¶
type Item struct { Key []byte SubKey []byte Value []byte Exists bool Timestamp int64 TTL int Index int Sync bool }
func MergeItems ¶
MergeItems will merge the given slices of Items into a slice with the newest version of each Item, with regard to their keys.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring contains an ordered set of routes to discord.Nodes. It can fetch predecessor, match and successor for any key or remote (remotes are ordeded first on position, then on address, so that we have a defined orded even between nodes with the same position).
func NewRingNodes ¶
func (*Ring) Add ¶
Add adds r to this Ring. If a Node with the same address is already present, it will be updated if needed.
func (*Ring) AddChangeListener ¶
func (self *Ring) AddChangeListener(f RingChangeListener)
func (*Ring) Clean ¶
Clean removes any Nodes in this Ring between predecessor and successor (exclusive).
func (*Ring) GetSlot ¶
GetSlot returns the biggest free spot in this Ring, assuming a maximum size 2 ^ (murmur.Size * 8).
func (*Ring) Predecessor ¶
func (*Ring) Redundancy ¶
Redundancy returns the minimum of the number of nodes present and the Redundancy const.
func (*Ring) Remotes ¶
Remotes returns the predecessor of pos, any Remote at pos and the successor of pos.
type RingChangeListener ¶
RingChangeListener is a function listening to changes in a Ring (ie changes in Node composition or position).
type Switchboard ¶
type Switchboard struct {
// contains filtered or unexported fields
}
Switchboard is a simple map of net/rpc.Clients, to avoid having to set up new connections for each remote call.
func (*Switchboard) Call ¶
func (self *Switchboard) Call(addr, service string, args, reply interface{}) (err error)
type TimeLock ¶
type TimeLock struct {
// contains filtered or unexported fields
}
func NewTimeLock ¶
func NewTimeLock() *TimeLock