smegmesh/pkg/sync/syncscheduler.go

18 lines
431 B
Go
Raw Normal View History

2023-10-10 21:14:40 +02:00
package sync
import (
"github.com/tim-beatham/wgmesh/pkg/ctrlserver"
"github.com/tim-beatham/wgmesh/pkg/lib"
2023-10-10 21:14:40 +02:00
)
// Run implements SyncScheduler.
func syncFunction(syncer Syncer) lib.TimerFunc {
return func() error {
return syncer.SyncMeshes()
2023-10-10 21:14:40 +02:00
}
}
func NewSyncScheduler(s *ctrlserver.MeshCtrlServer, syncRequester SyncRequester, syncer Syncer) *lib.Timer {
return lib.NewTimer(syncFunction(syncer), int(s.Conf.SyncRate))
2023-10-10 21:14:40 +02:00
}