nodeconf update interval config

This commit is contained in:
Sergey Cherepanov authored and Mikhail Iudin committed 2023-04-24 15:04:11 +02:00
1 parent 2ec5960b2b
commit fabaf676b8
2 files changed
+10 -1

No files matched your search

+4
View File
@@ -9,6 +9,10 @@ type ConfigGetter interface {
GetNodeConf() Configuration
}
type ConfigUpdateGetter interface {
GetNodeConfUpdateInterval() int
}
var (
ErrConfigurationNotFound = errors.New("node nodeConf not found")
)
+6 -1
View File
@@ -49,7 +49,12 @@ func (s *service) Init(a *app.App) (err error) {
lastStored = s.config
err = nil
}
s.sync = periodicsync.NewPeriodicSync(600, 0, func(ctx context.Context) (err error) {
var updatePeriodSec = 600
if confUpd, ok := a.MustComponent("config").(ConfigUpdateGetter); ok && confUpd.GetNodeConfUpdateInterval() > 0 {
updatePeriodSec = confUpd.GetNodeConfUpdateInterval()
}
s.sync = periodicsync.NewPeriodicSync(updatePeriodSec, 0, func(ctx context.Context) (err error) {
err = s.updateConfiguration(ctx)
if err != nil {
if err == ErrConfigurationNotChanged {