server: clean new func
parent
46974ef473
commit
9746de91bf
16
etcd/etcd.go
16
etcd/etcd.go
|
@ -66,13 +66,13 @@ type Server struct {
|
|||
|
||||
client *v2client
|
||||
rh *raftHandler
|
||||
node *v2Raft
|
||||
store.Store
|
||||
|
||||
// participant mode vars
|
||||
proposal chan v2Proposal
|
||||
addNodeC chan raft.Config
|
||||
removeNodeC chan raft.Config
|
||||
node *v2Raft
|
||||
store.Store
|
||||
|
||||
// standby mode vars
|
||||
leader int64
|
||||
|
@ -105,6 +105,7 @@ func New(c *config.Config, id int64) *Server {
|
|||
tr := new(http.Transport)
|
||||
tr.TLSClientConfig = tc
|
||||
client := &http.Client{Transport: tr}
|
||||
peerHub := newPeerHub(client)
|
||||
|
||||
s := &Server{
|
||||
config: c,
|
||||
|
@ -113,25 +114,22 @@ func New(c *config.Config, id int64) *Server {
|
|||
raftPubAddr: c.Peer.Addr,
|
||||
|
||||
nodes: make(map[string]bool),
|
||||
peerHub: newPeerHub(client),
|
||||
peerHub: peerHub,
|
||||
|
||||
tickDuration: defaultTickDuration,
|
||||
|
||||
client: newClient(tc),
|
||||
rh: newRaftHandler(peerHub),
|
||||
|
||||
node: &v2Raft{
|
||||
Node: raft.New(id, defaultHeartbeat, defaultElection),
|
||||
result: make(map[wait]chan interface{}),
|
||||
},
|
||||
|
||||
addNodeC: make(chan raft.Config),
|
||||
removeNodeC: make(chan raft.Config),
|
||||
client: newClient(tc),
|
||||
|
||||
Store: store.New(),
|
||||
|
||||
modeC: make(chan int, 10),
|
||||
stop: make(chan struct{}),
|
||||
}
|
||||
s.rh = newRaftHandler(s.peerHub)
|
||||
|
||||
for _, seed := range c.Peers {
|
||||
s.nodes[seed] = true
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
func TestMultipleNodes(t *testing.T) {
|
||||
tests := []int{1, 3, 5}
|
||||
tests := []int{1, 3, 5, 9, 11}
|
||||
|
||||
for _, tt := range tests {
|
||||
es, hs := buildCluster(tt, false)
|
||||
|
@ -196,6 +196,7 @@ func TestRemove(t *testing.T) {
|
|||
}
|
||||
}
|
||||
afterTest(t)
|
||||
// ensure that no goroutines are running
|
||||
TestGoroutinesRunning(t)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue