Esempio n. 1
0
// NewNode returns a new instance of Node.
func NewNode() *Node {
	n := &Node{Log: raft.NewLog()}
	n.Log.FSM = &FSM{}
	n.Log.Clock = raft.NewMockClock()
	n.Log.Rand = seq()
	if !testing.Verbose() {
		n.Log.Logger = log.New(ioutil.Discard, "", 0)
	}
	return n
}
Esempio n. 2
0
// NewBroker returns a new instance of a Broker with default values.
func NewBroker() *Broker {
	b := &Broker{
		log:      raft.NewLog(),
		replicas: make(map[uint64]*Replica),
		topics:   make(map[uint64]*topic),
		Logger:   log.New(os.Stderr, "[broker] ", log.LstdFlags),
	}
	b.log.FSM = (*brokerFSM)(b)
	return b
}
Esempio n. 3
0
// NewLog returns a new instance of Log.
func NewLog(u *url.URL) *Log {
	l := &Log{Log: raft.NewLog(), Clock: NewClock()}
	l.URL = u
	l.Log.Clock = l.Clock
	l.Rand = seq()
	l.DebugEnabled = true
	if !testing.Verbose() {
		l.Logger = log.New(ioutil.Discard, "", 0)
	}
	return l
}