From 70cb5aec9f2395a8031a6283c3ec0eeb6a3c2582 Mon Sep 17 00:00:00 2001 From: pb Date: Tue, 11 Mar 2025 12:03:35 +0100 Subject: [PATCH] changed some variable name for better understanding of process in LaunchPeerExecution --- models/peer/peer_cache.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index 2c96a68..4b84442 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -69,6 +69,7 @@ func (p *PeerCache) checkPeerStatus(peerID string, appName string) (*Peer, bool) } // LaunchPeerExecution launches an execution on a peer +// The method contacts the path described by : peer.Url + datatype path (from enums) + replacement of id by dataID func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, dt tools.DataType, method tools.METHOD, body interface{}, caller *tools.HTTPCaller) (*PeerExecution, error) { fmt.Println("Launching peer execution on", caller.URLS, dt, method) @@ -76,8 +77,8 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, if m, ok := methods[method]; !ok || m == "" { return nil, errors.New("no path found") } - meth := methods[method] // Get the method url to execute - meth = strings.ReplaceAll(meth, ":id", dataID) // Replace the id in the url in case of a DELETE / UPDATE method (it's a standard naming in OC) + path := methods[method] // Get the path corresponding to the action we want to execute + path = strings.ReplaceAll(path, ":id", dataID) // Replace the id in the path in case of a DELETE / UPDATE method (it's a standard naming in OC) url := "" // Check the status of the peer @@ -85,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) + meth, + Url: p.urlFormat((mypeer.Url), dt) + path, // the url is constitued of : host URL + resource path + action path (ex : mypeer.com/datacenter/resourcetype/path/to/action) Body: body, DataType: dt.EnumIndex(), DataID: dataID, @@ -98,7 +99,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, return nil, errors.New("peer not found") } // If the peer is reachable, launch the execution - url = p.urlFormat((mypeer.Url), dt) + meth // Format the URL + url = p.urlFormat((mypeer.Url), 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