Discovery Nats automate

This commit is contained in:
mr 2024-08-23 08:23:24 +02:00
parent 37b7ed8d83
commit 2ad4c0bb91
2 changed files with 6 additions and 5 deletions

View File

@ -11,8 +11,9 @@ import (
type Peer struct {
utils.AbstractObject
Url string `json:"url,omitempty" bson:"url,omitempty" validate:"required,base64url"`
PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"`
Url string `json:"url,omitempty" bson:"url,omitempty" validate:"required,base64url"`
PublicKey string `json:"public_key,omitempty" bson:"public_key,omitempty"`
State tools.State `json:"state,omitempty" bson:"state,omitempty"`
}
func (ao *Peer) IsMySelf() bool {

View File

@ -55,19 +55,19 @@ func (p *PeerCache) checkPeerStatus(peerID string, caller *tools.HTTPCaller) boo
return false
}
methods := caller.URLS[utils.PEER.String()]
fmt.Println("checkPeerStatus AFT 3", methods)
if methods == nil {
return false
}
meth := methods[tools.POST]
fmt.Println("checkPeerStatus AFT 4", meth)
if meth == "" {
return false
}
url := p.urlFormat(res.(*Peer).Url+meth, utils.PEER)
fmt.Println("checkPeerStatus AFT 4", 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
}