Booking trace API
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user