etcdserver: rename defaultPublishRetryInterval -> defaultPublishTimeout

This makes code more readable and reasonable.
This commit is contained in:
Yicheng Qin 2015-07-23 10:09:28 -07:00
parent 6be02ff5ec
commit b7892b20c1

View File

@ -55,7 +55,7 @@ const (
defaultSyncTimeout = time.Second defaultSyncTimeout = time.Second
DefaultSnapCount = 10000 DefaultSnapCount = 10000
// TODO: calculate based on heartbeat interval // TODO: calculate based on heartbeat interval
defaultPublishRetryInterval = 5 * time.Second defaultPublishTimeout = 5 * time.Second
StoreClusterPrefix = "/0" StoreClusterPrefix = "/0"
StoreKeysPrefix = "/1" StoreKeysPrefix = "/1"
@ -335,7 +335,7 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
// It also starts a goroutine to publish its server information. // It also starts a goroutine to publish its server information.
func (s *EtcdServer) Start() { func (s *EtcdServer) Start() {
s.start() s.start()
go s.publish(defaultPublishRetryInterval) go s.publish(defaultPublishTimeout)
go s.purgeFile() go s.purgeFile()
go monitorFileDescriptor(s.done) go monitorFileDescriptor(s.done)
go s.monitorVersions() go s.monitorVersions()
@ -689,7 +689,7 @@ func (s *EtcdServer) sync(timeout time.Duration) {
// static clientURLs of the server. // static clientURLs of the server.
// The function keeps attempting to register until it succeeds, // The function keeps attempting to register until it succeeds,
// or its server is stopped. // or its server is stopped.
func (s *EtcdServer) publish(retryInterval time.Duration) { func (s *EtcdServer) publish(timeout time.Duration) {
b, err := json.Marshal(s.attributes) b, err := json.Marshal(s.attributes)
if err != nil { if err != nil {
plog.Panicf("json marshal error: %v", err) plog.Panicf("json marshal error: %v", err)
@ -702,7 +702,7 @@ func (s *EtcdServer) publish(retryInterval time.Duration) {
} }
for { for {
ctx, cancel := context.WithTimeout(context.Background(), retryInterval) ctx, cancel := context.WithTimeout(context.Background(), timeout)
_, err := s.Do(ctx, req) _, err := s.Do(ctx, req)
cancel() cancel()
switch err { switch err {