Beispiel #1
0
// NewConn creates a new Conn to a cluster defined by the address of one of its members.
func NewConn(addr string) (result *Conn, err error) {
	result = &Conn{ring: common.NewRing()}
	var newNodes common.Remotes
	err = common.Switch.Call(addr, "Discord.Nodes", 0, &newNodes)
	result.ring.SetNodes(newNodes)
	return
}
Beispiel #2
0
func NewNode(listenAddr, broadcastAddr string) (result *Node) {
	return &Node{
		ring:          common.NewRing(),
		position:      make([]byte, murmur.Size),
		listenAddr:    listenAddr,
		broadcastAddr: broadcastAddr,
		exports:       make(map[string]interface{}),
		metaLock:      new(sync.RWMutex),
		routeLock:     new(sync.Mutex),
		state:         created,
	}
}