forked from TrueCloudLab/frostfs-node
[#316] ir/netmap: Validate LOCODE attributes of network map candidates
Define a structure for dealing with the geographic location of nodes. Implement VerifyAndUpdate (with the same purpose as NodeValidator interface) that checks LOCODE attribute and fills other attributes of the location. Technically the entity is a wrapper over the NeoFS location database: it maps the node LOCODE to the database record from which the new attributes are generated. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cbfaceb956
commit
db703a5117
4 changed files with 245 additions and 0 deletions
|
@ -0,0 +1,34 @@
|
|||
package locode
|
||||
|
||||
type attrDescriptor struct {
|
||||
optional bool
|
||||
converter func(Record) string
|
||||
}
|
||||
|
||||
func countryCodeValue(r Record) (val string) {
|
||||
return r.CountryCode().String()
|
||||
}
|
||||
|
||||
func countryValue(r Record) string {
|
||||
return r.CountryName()
|
||||
}
|
||||
|
||||
func locationCodeValue(r Record) string {
|
||||
return r.LocationCode().String()
|
||||
}
|
||||
|
||||
func locationValue(r Record) string {
|
||||
return r.LocationName()
|
||||
}
|
||||
|
||||
func subDivCodeValue(r Record) string {
|
||||
return r.SubDivCode()
|
||||
}
|
||||
|
||||
func subDivValue(r Record) string {
|
||||
return r.SubDivName()
|
||||
}
|
||||
|
||||
func continentValue(r Record) string {
|
||||
return r.Continent().String()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue