1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

nodeconf update interval config

This commit is contained in:
Sergey Cherepanov 2023-04-24 15:04:11 +02:00 committed by Mikhail Iudin
parent 2ec5960b2b
commit fabaf676b8
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
2 changed files with 10 additions and 1 deletions

View file

@ -9,6 +9,10 @@ type ConfigGetter interface {
GetNodeConf() Configuration
}
type ConfigUpdateGetter interface {
GetNodeConfUpdateInterval() int
}
var (
ErrConfigurationNotFound = errors.New("node nodeConf not found")
)

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 {