Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 != nil && 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