MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / startSyncTimer

Method startSyncTimer

internal/nodes/node.go:493–529  ·  view source on GitHub ↗

启动同步计时器

()

Source from the content-addressed store, hash-verified

491
492// 启动同步计时器
493func (this *Node) startSyncTimer() {
494 // TODO 这个时间间隔可以自行设置
495 var taskTicker = time.NewTicker(60 * time.Second)
496 var serverChangeTicker = time.NewTicker(5 * time.Second)
497
498 events.OnKey(events.EventQuit, this, func() {
499 remotelogs.Println("NODE", "quit sync timer")
500 taskTicker.Stop()
501 serverChangeTicker.Stop()
502 })
503 goman.New(func() {
504 for {
505 select {
506 case <-taskTicker.C: // 定期执行
507 err := this.loopTasks()
508 if err != nil {
509 remotelogs.Error("NODE", "sync config error: "+err.Error())
510 continue
511 }
512 case <-serverChangeTicker.C: // 服务变化
513 this.reloadServer()
514 case <-nodeTaskNotify: // 有新的更新任务
515 err := this.loopTasks()
516 if err != nil {
517 remotelogs.Error("NODE", "sync config error: "+err.Error())
518 continue
519 }
520 case <-nodeConfigChangedNotify: // 节点变化通知
521 err := this.syncConfig(0)
522 if err != nil {
523 remotelogs.Error("NODE", "sync config error: "+err.Error())
524 continue
525 }
526 }
527 }
528 })
529}
530
531// 检查集群设置
532func (this *Node) checkClusterConfig() error {

Callers 1

StartMethod · 0.95

Calls 9

loopTasksMethod · 0.95
reloadServerMethod · 0.95
syncConfigMethod · 0.95
OnKeyFunction · 0.92
PrintlnFunction · 0.92
NewFunction · 0.92
ErrorFunction · 0.92
StopMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected