2023-10-10 21:14:40 +02:00
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/tim-beatham/wgmesh/pkg/ctrlserver"
|
2023-11-06 14:37:28 +01:00
|
|
|
"github.com/tim-beatham/wgmesh/pkg/lib"
|
2023-10-10 21:14:40 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Run implements SyncScheduler.
|
2023-11-06 14:37:28 +01:00
|
|
|
func syncFunction(syncer Syncer) lib.TimerFunc {
|
|
|
|
return func() error {
|
2023-12-08 21:02:57 +01:00
|
|
|
syncer.SyncMeshes()
|
|
|
|
return nil
|
2023-10-10 21:14:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-28 15:42:09 +01:00
|
|
|
func NewSyncScheduler(s *ctrlserver.MeshCtrlServer, syncRequester SyncRequester, syncer Syncer) *lib.Timer {
|
2023-12-10 20:21:54 +01:00
|
|
|
return lib.NewTimer(syncFunction(syncer), s.Conf.SyncRate)
|
2023-10-10 21:14:40 +02:00
|
|
|
}
|