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

Method Start

internal/iplibrary/manager_ip_list.go:71–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69}
70
71func (this *IPListManager) Start() {
72 this.Init()
73
74 // 第一次读取
75 err := this.Loop()
76 if err != nil {
77 remotelogs.ErrorObject("IP_LIST_MANAGER", err)
78 }
79
80 this.ticker = time.NewTicker(60 * time.Second)
81 if Tea.IsTesting() {
82 this.ticker = time.NewTicker(10 * time.Second)
83 }
84 var countErrors = 0
85 for {
86 select {
87 case <-this.ticker.C:
88 case <-IPListUpdateNotify:
89 }
90 err = this.Loop()
91 if err != nil {
92 countErrors++
93
94 remotelogs.ErrorObject("IP_LIST_MANAGER", err)
95
96 // 连续错误小于3次的我们立即重试
97 if countErrors <= 3 {
98 select {
99 case IPListUpdateNotify <- true:
100 default:
101 }
102 }
103 } else {
104 countErrors = 0
105 }
106 }
107}
108
109func (this *IPListManager) Stop() {
110 if this.ticker != nil {

Callers

nothing calls this directly

Calls 3

InitMethod · 0.95
LoopMethod · 0.95
ErrorObjectFunction · 0.92

Tested by

no test coverage detected