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:
parent
2ec5960b2b
commit
fabaf676b8
2 changed files with 10 additions and 1 deletions
|
@ -9,6 +9,10 @@ type ConfigGetter interface {
|
|||
GetNodeConf() Configuration
|
||||
}
|
||||
|
||||
type ConfigUpdateGetter interface {
|
||||
GetNodeConfUpdateInterval() int
|
||||
}
|
||||
|
||||
var (
|
||||
ErrConfigurationNotFound = errors.New("node nodeConf not found")
|
||||
)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue