Discovery Nats automate
This commit is contained in:
parent
37b7ed8d83
commit
2ad4c0bb91
@ -13,6 +13,7 @@ type Peer struct {
|
|||||||
utils.AbstractObject
|
utils.AbstractObject
|
||||||
Url string `json:"url,omitempty" bson:"url,omitempty" validate:"required,base64url"`
|
Url string `json:"url,omitempty" bson:"url,omitempty" validate:"required,base64url"`
|
||||||
PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"`
|
PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"`
|
||||||
|
State tools.State `json:"state,omitempty" bson:"state,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ao *Peer) IsMySelf() bool {
|
func (ao *Peer) IsMySelf() bool {
|
||||||
|
@ -55,19 +55,19 @@ func (p *PeerCache) checkPeerStatus(peerID string, caller *tools.HTTPCaller) boo
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
methods := caller.URLS[utils.PEER.String()]
|
methods := caller.URLS[utils.PEER.String()]
|
||||||
fmt.Println("checkPeerStatus AFT 3", methods)
|
|
||||||
|
|
||||||
if methods == nil {
|
if methods == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
meth := methods[tools.POST]
|
meth := methods[tools.POST]
|
||||||
fmt.Println("checkPeerStatus AFT 4", meth)
|
|
||||||
if meth == "" {
|
if meth == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
url := p.urlFormat(res.(*Peer).Url+meth, utils.PEER)
|
url := p.urlFormat(res.(*Peer).Url+meth, utils.PEER)
|
||||||
fmt.Println("checkPeerStatus AFT 4", url)
|
|
||||||
state := api.CheckRemotePeer(url)
|
state := api.CheckRemotePeer(url)
|
||||||
|
res.(*Peer).State = state
|
||||||
|
access.UpdateOne(res, peerID)
|
||||||
|
fmt.Printf("Peer %v is %v\n", peerID, state)
|
||||||
return state != tools.DEAD
|
return state != tools.DEAD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user