cluster: migrate to using pkg/rings for Addresses [WIP]
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -70,3 +70,38 @@ func (z *Zone) GatewayIDs() ([]rings.NodeID, int) {
|
||||
|
||||
return out, len(out)
|
||||
}
|
||||
|
||||
// RegionID returns the primary [Region] of a [Zone].
|
||||
func (z *Zone) RegionID() rings.RegionID {
|
||||
if z != nil && z.region != nil {
|
||||
return z.region.ID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Is checks if the given [rings.RegionID] and [rings.ZoneID] match
|
||||
// the [Zone].
|
||||
func (z *Zone) Is(regionID rings.RegionID, zoneID rings.ZoneID) bool {
|
||||
switch {
|
||||
case z.ID != zoneID:
|
||||
return false
|
||||
case z.RegionID() != regionID:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Eq checks if two [Zone]s are the same.
|
||||
func (z *Zone) Eq(z2 *Zone) bool {
|
||||
switch {
|
||||
case z == nil, z2 == nil:
|
||||
return false
|
||||
case z.ID != z2.ID:
|
||||
return false
|
||||
case z.RegionID() != z2.RegionID():
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user