mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-08-18 17:08:15 +02:00
53-run-commands-pre-up-and-post-down
- Ability to run a command pre up and post down - Ability to be a client in one mesh and a peer in the other - Added dev card to specify different sync rate, keepalive rate per mesh.
This commit is contained in:
@@ -24,7 +24,7 @@ type SyncerImpl struct {
|
||||
infectionCount int
|
||||
syncCount int
|
||||
cluster conn.ConnCluster
|
||||
conf *conf.WgMeshConfiguration
|
||||
conf *conf.DaemonConfiguration
|
||||
lastSync uint64
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@ func (s *SyncerImpl) Sync(meshId string) error {
|
||||
// Self can be nil if the node is removed
|
||||
self, _ := s.manager.GetSelf(meshId)
|
||||
|
||||
s.manager.GetMesh(meshId).Prune()
|
||||
correspondingMesh := s.manager.GetMesh(meshId)
|
||||
|
||||
correspondingMesh.Prune()
|
||||
|
||||
if self != nil && self.GetType() == conf.PEER_ROLE && !s.manager.HasChanges(meshId) && s.infectionCount == 0 {
|
||||
logging.Log.WriteInfof("No changes for %s", meshId)
|
||||
@@ -47,7 +49,7 @@ func (s *SyncerImpl) Sync(meshId string) error {
|
||||
|
||||
logging.Log.WriteInfof(publicKey.String())
|
||||
|
||||
nodeNames := s.manager.GetMesh(meshId).GetPeers()
|
||||
nodeNames := correspondingMesh.GetPeers()
|
||||
|
||||
if self != nil {
|
||||
nodeNames = lib.Filter(nodeNames, func(s string) bool {
|
||||
@@ -133,7 +135,7 @@ func (s *SyncerImpl) SyncMeshes() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewSyncer(m mesh.MeshManager, conf *conf.WgMeshConfiguration, r SyncRequester) Syncer {
|
||||
func NewSyncer(m mesh.MeshManager, conf *conf.DaemonConfiguration, r SyncRequester) Syncer {
|
||||
cluster, _ := conn.NewConnCluster(conf.ClusterSize)
|
||||
return &SyncerImpl{
|
||||
manager: m,
|
||||
|
@@ -91,7 +91,7 @@ func (s *SyncRequesterImpl) SyncMesh(meshId string, meshNode mesh.MeshNode) erro
|
||||
|
||||
c := rpc.NewSyncServiceClient(client)
|
||||
|
||||
syncTimeOut := s.server.Conf.SyncRate * float64(time.Second)
|
||||
syncTimeOut := float64(s.server.Conf.SyncRate) * float64(time.Second)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(syncTimeOut))
|
||||
defer cancel()
|
||||
|
@@ -14,5 +14,5 @@ func syncFunction(syncer Syncer) lib.TimerFunc {
|
||||
}
|
||||
|
||||
func NewSyncScheduler(s *ctrlserver.MeshCtrlServer, syncRequester SyncRequester, syncer Syncer) *lib.Timer {
|
||||
return lib.NewTimer(syncFunction(syncer), int(s.Conf.SyncRate))
|
||||
return lib.NewTimer(syncFunction(syncer), s.Conf.SyncRate)
|
||||
}
|
||||
|
Reference in New Issue
Block a user