[#XX] locode: Introduce locode overriding
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
663e7c715b
commit
9637ed49ee
4 changed files with 80 additions and 6 deletions
|
@ -4,6 +4,8 @@ import (
|
|||
"fmt"
|
||||
"io/fs"
|
||||
"sync"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-locode-db/pkg/locode"
|
||||
)
|
||||
|
||||
// Prm groups the required parameters of the Table's constructor.
|
||||
|
@ -21,6 +23,11 @@ type Prm struct {
|
|||
//
|
||||
// Must not be empty.
|
||||
SubDivPath string
|
||||
|
||||
// Path to a csv table with UN/LOCODE overrides.
|
||||
//
|
||||
// Optional.
|
||||
OverridesPath string
|
||||
}
|
||||
|
||||
// Table is a descriptor of the UN/LOCODE table in csv format.
|
||||
|
@ -39,6 +46,12 @@ type Table struct {
|
|||
subDivOnce sync.Once
|
||||
|
||||
mSubDiv map[subDivKey]subDivRecord
|
||||
|
||||
overridesPath string
|
||||
|
||||
overridesOnce sync.Once
|
||||
|
||||
overrides map[locode.LOCODE]locode.Record
|
||||
}
|
||||
|
||||
const invalidPrmValFmt = "invalid parameter %s (%T):%v"
|
||||
|
@ -68,8 +81,9 @@ func New(prm Prm, opts ...Option) *Table {
|
|||
}
|
||||
|
||||
return &Table{
|
||||
paths: append(o.extraPaths, prm.Path),
|
||||
mode: o.mode,
|
||||
subDivPath: prm.SubDivPath,
|
||||
paths: append(o.extraPaths, prm.Path),
|
||||
overridesPath: prm.OverridesPath,
|
||||
mode: o.mode,
|
||||
subDivPath: prm.SubDivPath,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue