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

Method Loop

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

Source from the content-addressed store, hash-verified

166}
167
168func (this *IPListManager) Loop() error {
169 // 是否同步IP名单
170 nodeConfig, _ := nodeconfigs.SharedNodeConfig()
171 if nodeConfig != nil && !nodeConfig.EnableIPLists {
172 return nil
173 }
174
175 // 第一次同步则打印信息
176 if this.isFirstTime {
177 remotelogs.Println("IP_LIST_MANAGER", "initializing ip items ...")
178 }
179
180 for {
181 hasNext, err := this.fetch()
182 if err != nil {
183 return err
184 }
185 if !hasNext {
186 break
187 }
188 time.Sleep(1 * time.Second)
189 }
190
191 // 第一次同步则打印信息
192 if this.isFirstTime {
193 this.isFirstTime = false
194 remotelogs.Println("IP_LIST_MANAGER", "finished initializing ip items")
195 }
196
197 return nil
198}
199
200func (this *IPListManager) fetch() (hasNext bool, err error) {
201 rpcClient, err := rpc.SharedRPC()

Callers 2

StartMethod · 0.95
TestIPListManager_loopFunction · 0.45

Calls 2

fetchMethod · 0.95
PrintlnFunction · 0.92

Tested by 1

TestIPListManager_loopFunction · 0.36