[#1619] logger: Review
All checks were successful
DCO action / DCO (pull_request) Successful in 29s
Vulncheck / Vulncheck (pull_request) Successful in 56s
Tests and linters / Run gofumpt (pull_request) Successful in 1m16s
Build / Build Components (pull_request) Successful in 1m36s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m37s
Tests and linters / Staticcheck (pull_request) Successful in 2m17s
Tests and linters / Lint (pull_request) Successful in 3m7s
Tests and linters / Tests (pull_request) Successful in 4m41s
Tests and linters / Tests with -race (pull_request) Successful in 5m34s
Tests and linters / gopls check (pull_request) Successful in 5m32s

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2025-02-11 16:44:16 +03:00
parent 30223662fd
commit d2ebed13c4
3 changed files with 20 additions and 20 deletions

View file

@ -697,15 +697,19 @@ func initCfg(appCfg *config.Config) *cfg {
}
initLocalNodeInfo(c, key, netAddr, attrs)
locodeDB := locodebolt.New(locodebolt.Prm{
Path: nodeconfig.LocodeDBPath(appCfg),
},
locodebolt.ReadOnly(),
)
err := locodeDB.Open()
fatalOnErr(err)
var locodeDB *locodebolt.DB
locodeDBPath := nodeconfig.LocodeDBPath(appCfg)
if len(locodeDBPath) > 0 {
locodeDB = locodebolt.New(locodebolt.Prm{
Path: locodeDBPath,
},
locodebolt.ReadOnly(),
)
err := locodeDB.Open()
fatalOnErr(err)
}
err = c.readConfig(appCfg, locodeDB, c.cfgNodeInfo.localInfo)
err := c.readConfig(appCfg, locodeDB, c.cfgNodeInfo.localInfo)
if err != nil {
panic(fmt.Errorf("config reading: %w", err))
}

View file

@ -40,8 +40,6 @@ const (
// PersistentStatePathDefault is a default path for persistent state file.
PersistentStatePathDefault = ".frostfs-storage-state"
pathToLocodeDBDefault = "/var/lib/frostfs/locode_db"
)
// Key returns the value of "key" config parameter
@ -222,9 +220,5 @@ func CompatibilityMode(c *config.Config) bool {
// LocodeDBPath returns path to LOCODE database.
func LocodeDBPath(c *config.Config) string {
v := config.String(c.Sub(subsection).Sub("locode"), "db_path")
if len(v) == 0 {
return pathToLocodeDBDefault
}
return v
return config.String(c.Sub(subsection).Sub("locode"), "db_path")
}

View file

@ -116,12 +116,14 @@ func getPoint(db *locodebolt.DB, raw string) (*locodedb.Point, error) {
return record.GeoPoint(), nil
}
func distance(lat1 float64, lng1 float64, lat2 float64, lng2 float64) float64 {
radlat1 := math.Pi * lat1 / 180
radlat2 := math.Pi * lat2 / 180
radtheta := math.Pi * (lng1 - lng2) / 180
// distance return amount of KM between two points.
// Parameters are latitude and longitude of point 1 and 2 in decimal degrees.
func distance(lt1 float64, ln1 float64, lt2 float64, ln2 float64) float64 {
radLat1 := math.Pi * lt1 / 180
radLat2 := math.Pi * lt2 / 180
radTheta := math.Pi * (ln1 - ln2) / 180
dist := math.Sin(radlat1)*math.Sin(radlat2) + math.Cos(radlat1)*math.Cos(radlat2)*math.Cos(radtheta)
dist := math.Sin(radLat1)*math.Sin(radLat2) + math.Cos(radLat1)*math.Cos(radLat2)*math.Cos(radTheta)
if dist > 1 {
dist = 1