Booking trace API

This commit is contained in:
mr
2024-08-21 16:03:56 +02:00
parent 6ef8cde225
commit 950bbf1d7b
4 changed files with 19 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ type PeerCache struct {
Executions []*PeerExecution
}
func (p *PeerCache) checkPeerStatus(peerID string) bool {
func (p *PeerCache) checkPeerStatus(peerID string, caller *tools.HTTPCaller) bool {
api := tools.API{}
access := (&Peer{}).GetAccessor(nil)
res, code, _ := access.LoadOne(peerID)
@@ -44,7 +44,15 @@ func (p *PeerCache) checkPeerStatus(peerID string) bool {
url = strings.ReplaceAll(url, "localhost", utils.PEER.API())
}
state := api.CheckRemotePeer(url + ":8093")
methods := caller.URLS[utils.PEER.String()]
if methods == nil {
return false
}
meth := methods[tools.POST]
if meth == "" {
return false
}
state := api.CheckRemotePeer(url + meth)
return state != tools.DEAD
}
@@ -69,7 +77,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, isMySelf bool, dataID str
if _, ok := methods[method]; !ok {
return nil, errors.New("no path found")
}
if !p.checkPeerStatus(peerID) {
if !p.checkPeerStatus(peerID, caller) {
return nil, err
}
if method == tools.POST {