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

Method fetch

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

Source from the content-addressed store, hash-verified

198}
199
200func (this *IPListManager) fetch() (hasNext bool, err error) {
201 rpcClient, err := rpc.SharedRPC()
202 if err != nil {
203 return false, err
204 }
205 itemsResp, err := rpcClient.IPItemRPC.ListIPItemsAfterVersion(rpcClient.Context(), &pb.ListIPItemsAfterVersionRequest{
206 Version: this.lastVersion,
207 Size: this.fetchPageSize,
208 })
209 if err != nil {
210 if rpc.IsConnError(err) {
211 remotelogs.Debug("IP_LIST_MANAGER", "rpc connection error: "+err.Error())
212 return false, nil
213 }
214 return false, err
215 }
216 var items = itemsResp.IpItems
217 if len(items) == 0 {
218 return false, nil
219 }
220
221 // 保存到本地数据库
222 if this.db != nil {
223 for _, item := range items {
224 err = this.db.AddItem(item)
225 if err != nil {
226 remotelogs.Error("IP_LIST_MANAGER", "insert item to local database failed: "+err.Error())
227 }
228 }
229 }
230
231 this.processItems(items, true)
232
233 return true, nil
234}
235
236func (this *IPListManager) FindList(listId int64) *IPList {
237 this.mu.RLock()

Callers 1

LoopMethod · 0.95

Calls 8

processItemsMethod · 0.95
SharedRPCFunction · 0.92
IsConnErrorFunction · 0.92
DebugFunction · 0.92
ErrorFunction · 0.92
ContextMethod · 0.80
AddItemMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected