Update try
This commit is contained in:
@@ -44,7 +44,7 @@ func CheckPeerStatus(peerID string, appName string) (*Peer, bool) {
|
||||
fmt.Println(url)
|
||||
state, services := api.CheckRemotePeer(url)
|
||||
res.(*Peer).ServicesState = services // Update the services states of the peer
|
||||
access.UpdateOne(res, peerID) // Update the peer in the db
|
||||
access.UpdateOne(res.Serialize(res), peerID) // Update the peer in the db
|
||||
return res.(*Peer), state != tools.DEAD && services[appName] == 0 // Return the peer and its status
|
||||
}
|
||||
|
||||
@@ -72,18 +72,18 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string,
|
||||
DataID: dataID,
|
||||
}
|
||||
mypeer.AddExecution(*pexec)
|
||||
NewShallowAccessor().UpdateOne(mypeer, peerID) // Update the peer in the db
|
||||
NewShallowAccessor().UpdateOne(mypeer.Serialize(mypeer), peerID) // Update the peer in the db
|
||||
return map[string]interface{}{}, errors.New("peer is " + peerID + " not reachable")
|
||||
} else {
|
||||
if mypeer == nil {
|
||||
return map[string]interface{}{}, errors.New("peer " + peerID + " not found")
|
||||
}
|
||||
// If the peer is reachable, launch the execution
|
||||
url = urlFormat((mypeer.APIUrl), dt) + path // Format the URL
|
||||
tmp := mypeer.FailedExecution // Get the failed executions list
|
||||
mypeer.FailedExecution = []PeerExecution{} // Reset the failed executions list
|
||||
NewShallowAccessor().UpdateOne(mypeer, peerID) // Update the peer in the db
|
||||
for _, v := range tmp { // Retry the failed executions
|
||||
url = urlFormat((mypeer.APIUrl), dt) + path // Format the URL
|
||||
tmp := mypeer.FailedExecution // Get the failed executions list
|
||||
mypeer.FailedExecution = []PeerExecution{} // Reset the failed executions list
|
||||
NewShallowAccessor().UpdateOne(mypeer.Serialize(mypeer), peerID) // Update the peer in the db
|
||||
for _, v := range tmp { // Retry the failed executions
|
||||
go p.Exec(v.Url, tools.ToMethod(v.Method), v.Body, caller)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user