removed caller from checkPeerStatus() parameters by adding the path to url
This commit is contained in:
@@ -48,28 +48,21 @@ func (p *PeerCache) urlFormat(url string, dt tools.DataType) string {
|
||||
url = strings.ReplaceAll(url, localhost, dt.API()+":8080/oc")
|
||||
}
|
||||
} else {
|
||||
url = url + "/" + strings.ReplaceAll(dt.API(), "oc-", "")
|
||||
url = url + "/" + dt.API()
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
// checkPeerStatus checks the status of a peer
|
||||
func (p *PeerCache) checkPeerStatus(peerID string, appName string, caller *tools.HTTPCaller) (*Peer, bool) {
|
||||
func (p *PeerCache) checkPeerStatus(peerID string, appName string) (*Peer, bool) {
|
||||
api := tools.API{}
|
||||
access := NewShallowAccessor()
|
||||
res, code, _ := access.LoadOne(peerID) // Load the peer from db
|
||||
if code != 200 { // no peer no party
|
||||
return nil, false
|
||||
}
|
||||
methods := caller.URLS[tools.PEER] // Get the methods url of the peer
|
||||
if methods == nil {
|
||||
return res.(*Peer), false
|
||||
}
|
||||
meth := methods[tools.POST] // Get the POST method to check status
|
||||
if meth == "" {
|
||||
return res.(*Peer), false
|
||||
}
|
||||
url := p.urlFormat(res.(*Peer).Url, tools.PEER) + meth // Format the URL
|
||||
|
||||
url := p.urlFormat(res.(*Peer).Url, tools.PEER) + "/status" // Format the 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
|
||||
@@ -89,7 +82,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string,
|
||||
url := ""
|
||||
|
||||
// Check the status of the peer
|
||||
if mypeer, ok := p.checkPeerStatus(peerID, dt.API(), caller); !ok && mypeer != nil {
|
||||
if mypeer, ok := p.checkPeerStatus(peerID, dt.API()); !ok && mypeer != nil {
|
||||
// If the peer is not reachable, add the execution to the failed executions list
|
||||
pexec := &PeerExecution{
|
||||
Method: method.String(),
|
||||
|
Reference in New Issue
Block a user