Пример #1
0
func New(sid int, filename string) raft {
	var raftinstance raft
	raftinstance.serverobj = cluster.New(sid, filename)
	raftinstance.term = 0
	raftinstance.sid = sid
	raftinstance.timeout = random(300, 600)
	raftinstance.state = FOLLOWER
	noofserverup += 1
	go raftinstance.serverresponse()
	return raftinstance
}
Пример #2
0
//Basic test to check whether messages are being sent or not.
func TestBasicPointToPoint(t *testing.T) {
	j := 100
	for i := 0; i < 10; i++ {
		s[i] = cluster.New(j, "configurationfile.json")
		j++
		time.Sleep(time.Millisecond)
	}

	s[0].Outbox() <- &cluster.Envelope{Pid: 101, Msg: "hello there"} // sending envelope to a channel

	if (<-s[1].Inbox()).Msg != "hello there" {
		t.Fail()
	}

}