datamanager: add function to get changegroups from etcd

This commit is contained in:
Simone Gotti 2019-04-29 10:13:13 +02:00
parent f5cf3b9fa7
commit 2634f7a3a0
1 changed files with 14 additions and 0 deletions

View File

@ -288,6 +288,20 @@ func (d *DataManager) ListEtcdWals(ctx context.Context, revision int64) <-chan *
return walCh return walCh
} }
func (d *DataManager) ListEtcdChangeGroups(ctx context.Context, revision int64) (changeGroupsRevisions, error) {
changeGroupsRevisions := changeGroupsRevisions{}
resp, err := d.e.List(ctx, etcdChangeGroupsDir, "", revision)
if err != nil {
return nil, err
}
for _, kv := range resp.Kvs {
changegroupID := path.Base(string(kv.Key))
changeGroupsRevisions[changegroupID] = kv.ModRevision
}
return changeGroupsRevisions, nil
}
// FirstAvailableWalData returns the first (the one with smaller sequence) wal // FirstAvailableWalData returns the first (the one with smaller sequence) wal
// and returns it (or nil if not available) and the etcd revision at the time of // and returns it (or nil if not available) and the etcd revision at the time of
// the operation // the operation