From 03e066c297c950595ac9f1184006fd663569f1d9 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 7 Oct 2024 14:39:02 +0200 Subject: [PATCH] missing datacenter resource --- models/peer/peer_cache.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index 8509136..516ab20 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -40,6 +40,8 @@ func (p *PeerCache) urlFormat(url string, dt tools.DataType) string { } url = strings.ReplaceAll(url, "localhost", dt.API()+":8080") url = strings.ReplaceAll(url, "127.0.0.1", dt.API()+":8080") + } else { + url = url + "/" + dt.API() } return url } @@ -84,7 +86,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, // If the peer is not reachable, add the execution to the failed executions list pexec := &PeerExecution{ Method: method.String(), - Url: p.urlFormat((mypeer.Url)+"/"+dt.API()+meth, dt), + Url: p.urlFormat((mypeer.Url)+meth, dt), Body: body, DataType: dt.EnumIndex(), DataID: dataID, @@ -94,11 +96,11 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, return nil, errors.New("peer is not reachable") } else { // If the peer is reachable, launch the execution - url = p.urlFormat((mypeer.Url)+"/"+dt.API()+meth, dt) // Format the URL - tmp := mypeer.FailedExecution // Get the failed executions list - mypeer.FailedExecution = []PeerExecution{} // Reset the failed executions list - mypeer.GetAccessor(nil).UpdateOne(mypeer, peerID) // Update the peer in the db - for _, v := range tmp { // Retry the failed executions + url = p.urlFormat((mypeer.Url)+meth, dt) // Format the URL + tmp := mypeer.FailedExecution // Get the failed executions list + mypeer.FailedExecution = []PeerExecution{} // Reset the failed executions list + mypeer.GetAccessor(nil).UpdateOne(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) } }