Skip to content

Commit

Permalink
netmap: Add LOCODE getters
Browse files Browse the repository at this point in the history
Required by SN after moving LOCOCE attributes extension from IR to SN side.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Nov 20, 2023
1 parent f5fda09 commit 10ad234
Showing 1 changed file with 63 additions and 7 deletions.
70 changes: 63 additions & 7 deletions netmap/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,15 @@ func (x NodeInfo) capacity() uint64 {
return capacity
}

const attrUNLOCODE = "UN-LOCODE"
const (
attrUNLOCODE = "UN-LOCODE"
attrCountryCode = "CountryCode"
attrCountryName = "Country"
attrLocation = "Location"
attrSubDivCode = "SubDivCode"
attrSubDivName = "SubDiv"
attrContinent = "Continent"
)

// SetLOCODE specifies node's geographic location in UN/LOCODE format. Each
// storage node MUST declare it for entrance to the NeoFS network. Node MAY
Expand All @@ -315,36 +323,84 @@ func (x NodeInfo) LOCODE() string {
// SetCountryCode sets code of the country in ISO 3166-1_alpha-2 to which
// storage node belongs (or the closest one).
func (x *NodeInfo) SetCountryCode(countryCode string) {
x.SetAttribute("CountryCode", countryCode)
x.SetAttribute(attrCountryCode, countryCode)
}

// CountryCode returns node's country code set using SetCountryCode.
//
// Zero NodeInfo has empty country code which is invalid according to
// NeoFS API system requirement.
func (x NodeInfo) CountryCode() string {
return x.Attribute(attrCountryCode)
}

// SetCountryName sets short name of the country in ISO-3166 format to which
// storage node belongs (or the closest one).
func (x *NodeInfo) SetCountryName(country string) {
x.SetAttribute("Country", country)
x.SetAttribute(attrCountryName, country)
}

// CountryName returns node's country name set using SetCountryName.
//
// Zero NodeInfo has empty country name which is invalid according to
// NeoFS API system requirement.
func (x NodeInfo) CountryName() string {
return x.Attribute(attrCountryName)
}

// SetLocationName sets storage node's location name from "NameWoDiacritics"
// column in the UN/LOCODE record corresponding to the specified LOCODE.
func (x *NodeInfo) SetLocationName(location string) {
x.SetAttribute("Location", location)
x.SetAttribute(attrLocation, location)
}

// LocationName returns node's location set using SetLocationName.
//
// Zero NodeInfo has empty location which is invalid according to
// NeoFS API system requirement.
func (x NodeInfo) LocationName() string {
return x.Attribute(attrLocation)
}

// SetSubdivisionCode sets storage node's subdivision code from "SubDiv" column in
// the UN/LOCODE record corresponding to the specified LOCODE.
func (x *NodeInfo) SetSubdivisionCode(subDiv string) {
x.SetAttribute("SubDivCode", subDiv)
x.SetAttribute(attrSubDivCode, subDiv)
}

// SubdivisionCode returns node's subdivision code set using SetSubdivisionCode.
//
// Zero NodeInfo has subdivision code which is invalid according to
// NeoFS API system requirement.
func (x NodeInfo) SubdivisionCode() string {
return x.Attribute(attrSubDivCode)
}

// SetSubdivisionName sets storage node's subdivision name in ISO 3166-2 format.
func (x *NodeInfo) SetSubdivisionName(subDiv string) {
x.SetAttribute("SubDiv", subDiv)
x.SetAttribute(attrSubDivName, subDiv)
}

// SubdivisionName returns node's subdivision name set using SetSubdivisionName.
//
// Zero NodeInfo has subdivision name which is invalid according to
// NeoFS API system requirement.
func (x NodeInfo) SubdivisionName() string {
return x.Attribute(attrSubDivName)
}

// SetContinentName sets name of the storage node's continent from
// Seven-Continent model.
func (x *NodeInfo) SetContinentName(continent string) {
x.SetAttribute("Continent", continent)
x.SetAttribute(attrContinent, continent)
}

// ContinentName returns node's continent set using SetContinentName.
//
// Zero NodeInfo has continent which is invalid according to
// NeoFS API system requirement.
func (x NodeInfo) ContinentName() string {
return x.Attribute(attrContinent)
}

// Enumeration of well-known attributes.
Expand Down

0 comments on commit 10ad234

Please sign in to comment.