mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix(peer): Pass peer server timeouts through factory
The peer's heartbeat and election timeouts are needed to build the transporter in the factory method.
This commit is contained in:
@@ -89,8 +89,8 @@ func NewConfig() *Config {
|
||||
c.MaxRetryAttempts = 3
|
||||
c.SnapshotCount = 10000
|
||||
c.Peer.Addr = "127.0.0.1:7001"
|
||||
c.Peer.HeartbeatTimeout = 0
|
||||
c.Peer.ElectionTimeout = 0
|
||||
c.Peer.HeartbeatTimeout = defaultHeartbeatTimeout
|
||||
c.Peer.ElectionTimeout = defaultElectionTimeout
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ type snapshotConf struct {
|
||||
snapshotThr uint64
|
||||
}
|
||||
|
||||
func NewPeerServer(name string, path string, url string, bindAddr string, tlsConf *TLSConfig, tlsInfo *TLSInfo, registry *Registry, store store.Store, snapshotCount int) *PeerServer {
|
||||
func NewPeerServer(name string, path string, url string, bindAddr string, tlsConf *TLSConfig, tlsInfo *TLSInfo, registry *Registry, store store.Store, snapshotCount int, heartbeatTimeout, electionTimeout time.Duration) *PeerServer {
|
||||
s := &PeerServer{
|
||||
name: name,
|
||||
url: url,
|
||||
@@ -85,8 +85,8 @@ func NewPeerServer(name string, path string, url string, bindAddr string, tlsCon
|
||||
back: -1,
|
||||
},
|
||||
},
|
||||
HeartbeatTimeout: defaultHeartbeatTimeout,
|
||||
ElectionTimeout: defaultElectionTimeout,
|
||||
HeartbeatTimeout: heartbeatTimeout,
|
||||
ElectionTimeout: electionTimeout,
|
||||
|
||||
timeoutThresholdChan: make(chan interface{}, 1),
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// The amount of time to elapse without a heartbeat before becoming a candidate
|
||||
defaultElectionTimeout = 200 * time.Millisecond
|
||||
// The amount of time (in ms) to elapse without a heartbeat before becoming a candidate
|
||||
defaultElectionTimeout = 200
|
||||
|
||||
// The frequency by which heartbeats are sent to followers.
|
||||
defaultHeartbeatTimeout = 50 * time.Millisecond
|
||||
// The frequency (in ms) by which heartbeats are sent to followers.
|
||||
defaultHeartbeatTimeout = 50
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user