Skip to content

Commit

Permalink
make etcd periodic member sync configurable and optional
Browse files Browse the repository at this point in the history
  • Loading branch information
vikstrous committed Nov 12, 2016
1 parent 1d84310 commit 7e560bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 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,13 +87,15 @@ func New(addrs []string, options *store.Config) (store.Store, error) {
s.client = etcd.NewKeysAPI(c)

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

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 7e560bb

Please sign in to comment.