George Bartolomey
9c2c76ca32
All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 4m47s
DCO action / DCO (pull_request) Successful in 4m40s
Build / Build Components (1.21) (pull_request) Successful in 7m27s
Tests and linters / Staticcheck (pull_request) Successful in 8m22s
Tests and linters / gopls check (pull_request) Successful in 10m56s
Build / Build Components (1.22) (pull_request) Successful in 11m48s
Tests and linters / Tests (1.22) (pull_request) Successful in 16m11s
Tests and linters / Lint (pull_request) Successful in 16m27s
Pre-commit hooks / Pre-commit (pull_request) Successful in 19m12s
Tests and linters / Tests (1.21) (pull_request) Successful in 20m31s
Tests and linters / Tests with -race (pull_request) Successful in 8m56s
Removed pkg/util/locode package, added git.frostfs.info/TrueCloudLab/frostfs-locode-db/pkg/locode dependency. Signed-off-by: George Bartolomey <george@bh4.ru>
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package innerring
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-locode-db/pkg/locode"
|
|
locodedb "git.frostfs.info/TrueCloudLab/frostfs-locode-db/pkg/locode/db"
|
|
locodebolt "git.frostfs.info/TrueCloudLab/frostfs-locode-db/pkg/locode/db/boltdb"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap"
|
|
irlocode "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/locode"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func (s *Server) newLocodeValidator(cfg *viper.Viper) (netmap.NodeValidator, error) {
|
|
locodeDB := locodebolt.New(locodebolt.Prm{
|
|
Path: cfg.GetString("locode.db.path"),
|
|
},
|
|
locodebolt.ReadOnly(),
|
|
)
|
|
|
|
s.registerStarter(locodeDB.Open)
|
|
s.registerIOCloser(locodeDB)
|
|
|
|
return irlocode.New(irlocode.Prm{
|
|
DB: (*locodeBoltDBWrapper)(locodeDB),
|
|
}), nil
|
|
}
|
|
|
|
type locodeBoltEntryWrapper struct {
|
|
*locodedb.Key
|
|
*locodedb.Record
|
|
}
|
|
|
|
func (l *locodeBoltEntryWrapper) LocationName() string {
|
|
return l.Record.LocationName()
|
|
}
|
|
|
|
type locodeBoltDBWrapper locodebolt.DB
|
|
|
|
func (l *locodeBoltDBWrapper) Get(lc *locode.LOCODE) (irlocode.Record, error) {
|
|
key, err := locodedb.NewKey(*lc)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
rec, err := (*locodebolt.DB)(l).Get(*key)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &locodeBoltEntryWrapper{
|
|
Key: key,
|
|
Record: rec,
|
|
}, nil
|
|
}
|