Browse Source

cluster: decouple getRegion() from finishRegion()

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/43/head
Alejandro Mery 8 months ago
parent
commit
173dba0c3b
  1. 13
      pkg/cluster/regions.go

13
pkg/cluster/regions.go

@ -168,7 +168,7 @@ func (m *Cluster) finishRegion(r *Region) {
r.m = m
sub := []string{}
for _, name := range r.Regions {
r2, ok := m.getRegion(name)
r2, ok := m.getFinishRegion(name)
if !ok {
m.warn(nil).WithField("region", name).Print("unknown region")
continue
@ -183,9 +183,7 @@ func (m *Cluster) finishRegion(r *Region) {
func (m *Cluster) getRegion(name string) (*Region, bool) {
for i := range m.Regions {
r := &m.Regions[i]
if name == r.Name {
m.finishRegion(r)
return r, true
}
}
@ -193,6 +191,15 @@ func (m *Cluster) getRegion(name string) (*Region, bool) {
return nil, false
}
func (m *Cluster) getFinishRegion(name string) (*Region, bool) {
if r, ok := m.getRegion(name); ok {
m.finishRegion(r)
return r, true
}
return nil, false
}
// SyncRegions writes to the file system the regions this [Zone]
// belongs to.
func (z *Zone) SyncRegions() error {

Loading…
Cancel
Save