Skip to content

Commit

Permalink
make etcd periodic member sync configurable and optional
Browse files Browse the repository at this point in the history
fix docker#137

Signed-off-by: Viktor Stanchev <[email protected]>
  • Loading branch information
vikstrous authored and abronan committed Aug 12, 2017
1 parent 0517c63 commit aa80c88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions store/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type etcdLock struct {
}

const (
periodicSync = 5 * time.Minute
defaultLockTTL = 20 * time.Second
defaultUpdateTime = 5 * time.Second
)
Expand Down Expand Up @@ -88,11 +87,13 @@ func New(addrs []string, options *store.Config) (store.Store, error) {
s.client = etcd.NewKeysAPI(c)

// Periodic Cluster Sync
go func() {
for {
c.AutoSync(context.Background(), periodicSync)
}
}()
if options != nil && options.SyncPeriod != 0 {
go func() {
for {
c.AutoSync(context.Background(), options.SyncPeriod)
}
}()
}

return s, nil
}
Expand Down
1 change: 1 addition & 0 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Config struct {
ClientTLS *ClientTLSConfig
TLS *tls.Config
ConnectionTimeout time.Duration
SyncPeriod time.Duration
Bucket string
PersistConnection bool
Username string
Expand Down

0 comments on commit aa80c88

Please sign in to comment.