Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
hotfix GetTopology
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Konovalov committed Sep 3, 2024
1 parent 47da6c7 commit 5d34e43
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions providers/etcd/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ func mapCluster2Instances(replicasets []vshardrouter.ReplicasetInfo,
return currentTopology
}

func (p *Provider) GetTopology(nodes client.Nodes) (map[vshardrouter.ReplicasetInfo][]vshardrouter.InstanceInfo, error) {
func (p *Provider) GetTopology() (map[vshardrouter.ReplicasetInfo][]vshardrouter.InstanceInfo, error) {
resp, err := p.kapi.Get(context.TODO(), p.path, &client.GetOptions{Recursive: true})
if err != nil {
return nil, err
}
nodes := resp.Node.Nodes

if nodes.Len() < 2 {
return nil, fmt.Errorf("etcd path %s subnodes <2; minimum 2 (/clusters & /instances)", p.path)
}
Expand Down Expand Up @@ -140,12 +146,7 @@ func (p *Provider) GetTopology(nodes client.Nodes) (map[vshardrouter.ReplicasetI
}

func (p *Provider) Init(c vshardrouter.TopologyController) error {
resp, err := p.kapi.Get(context.TODO(), p.path, &client.GetOptions{Recursive: true})
if err != nil {
return err
}

topology, err := p.GetTopology(resp.Node.Nodes)
topology, err := p.GetTopology()
if err != nil {
return err
}
Expand Down

0 comments on commit 5d34e43

Please sign in to comment.