discord

package
v0.0.0-...-e1dc7cb Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2013 License: BSD-2-Clause-Views Imports: 9 Imported by: 0

README

discord

The routing bits and pieces of god. Mimics a chord network, except that it routes O(1) and grows O(n) instead of doing both O(log(n)).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommListener

type CommListener func(source, dest common.Remote, typ string) bool

CommListener is a function listening for generic communication between two Nodes.

type Node

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

Node is a node in a chord like cluster.

Like chord networks, it is a ring of nodes ordered by a position metric. Unlike chord, every node has every other node in its routing table. This allows stable networks to route with a constant time complexity.

func NewNode

func NewNode(listenAddr, broadcastAddr string) (result *Node)

func (*Node) AddChangeListener

func (self *Node) AddChangeListener(f common.RingChangeListener)

func (*Node) AddCommListener

func (self *Node) AddCommListener(f CommListener)

func (*Node) CountNodes

func (self *Node) CountNodes() int

CountNodes returns the number of Nodes in the ring.

func (*Node) Describe

func (self *Node) Describe() string

Describe returns a humanly readable string describing the broadcast address, position and ring of this Node.

func (*Node) Export

func (self *Node) Export(name string, api interface{}) error

Export will export the given api on a net/rpc server running on this Node.

func (*Node) GetBroadcastAddr

func (self *Node) GetBroadcastAddr() string

func (*Node) GetListenAddr

func (self *Node) GetListenAddr() string

func (*Node) GetNodes

func (self *Node) GetNodes() (result common.Remotes)

GetNodes will return remotes to all Nodes in the ring.

func (*Node) GetPosition

func (self *Node) GetPosition() (result []byte)

func (*Node) GetPredecessor

func (self *Node) GetPredecessor() common.Remote

GetPredecessor will return our predecessor on the ring.

func (*Node) GetPredecessorFor

func (self *Node) GetPredecessorFor(key []byte) common.Remote

GetPredecessorFor will return the predecessor for the provided key.

func (*Node) GetPredecessorForRemote

func (self *Node) GetPredecessorForRemote(r common.Remote) common.Remote

GetPredecessorForRemote will return the predecessor for the provided remote.

func (*Node) GetSuccessor

func (self *Node) GetSuccessor() common.Remote

GetSuccessor will return our successor on the ring.

func (*Node) GetSuccessorFor

func (self *Node) GetSuccessorFor(key []byte) common.Remote

GetSuccessorFor will return the successor for the provided key. If the successor is not this Node, it will assert that the provided key is between the found successor and the predecessor it claims to have.

func (*Node) GetSuccessorForRemote

func (self *Node) GetSuccessorForRemote(r common.Remote) common.Remote

GetSuccessorFor will return the successor for the provided remote.

func (*Node) HasNode

func (self *Node) HasNode(pos []byte) bool

HasNode will return true if there is a Node on the ring with the given pos.

func (*Node) Join

func (self *Node) Join(addr string) (err error)

Join will fetch the routing ring of the Node at addr, pick a location on an empty spot in the received ring and notify the other Node of our joining.

func (*Node) MustJoin

func (self *Node) MustJoin(addr string)

func (*Node) MustStart

func (self *Node) MustStart()

func (*Node) Nodes

func (self *Node) Nodes() common.Remotes

Nodes will return remotes for all Nodes in the ring.

func (*Node) Notify

func (self *Node) Notify(caller common.Remote) common.Remote

Notify will add the caller to the ring of this Node.

func (*Node) Ping

func (self *Node) Ping(ping PingPack) (me common.Remote)

Ping will compare the hash of this Node with the one in the received PingPack, and request the entire routing ring from the sender if they are not equal.

func (*Node) Redundancy

func (self *Node) Redundancy() int

Redundancy will return the current maximum redundancy in the ring.

func (*Node) Remote

func (self *Node) Remote() common.Remote

Remote returns a remote to this Node.

func (*Node) RemoveNode

func (self *Node) RemoveNode(remote common.Remote)

RemoveNode will remove the provided remote from our routing ring.

func (*Node) RingHash

func (self *Node) RingHash() []byte

RingHash returns a hash of the discord ring of this Node.

func (*Node) SetPosition

func (self *Node) SetPosition(position []byte) *Node

func (*Node) Start

func (self *Node) Start() (err error)

Start will spin up this Node, export all its api interfaces and start its notify and ping jobs.

func (*Node) Stop

func (self *Node) Stop()

Stop will shut down this Node permanently.

func (*Node) String

func (self *Node) String() string

type PingPack

type PingPack struct {
	Caller   common.Remote
	RingHash []byte
}

PingPack contains the sender and a hash of its discord ring, to let the receiver compare to its current ring.

Jump to

Keyboard shortcuts

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