A client connecting to another gossip node.
More...
#include <GossipPeerNode.h>
A client connecting to another gossip node.
Class GossipPeerNode is a async rpc client of Gossip Service and stores status of peer node.
◆ GossipPeerNode()
gossip::server::GossipPeerNode::GossipPeerNode |
( |
std::string |
name, |
|
|
std::string |
address, |
|
|
SlotVersion |
version, |
|
|
GossipNode * |
node |
|
) |
| |
|
explicit |
Constructor of GossipPeerNode.
- Parameters
-
name | The name of peer node |
address | The ip address of peer node |
version | The version of peer node |
node | The owner node of this class |
◆ address()
std::string gossip::server::GossipPeerNode::address |
( |
| ) |
|
|
inline |
Get the ip address of peer node.
- Returns
- The ip address of peer node
◆ deleteNodeNotify() [1/2]
Async. Send a node delete notify request to connected peer node. Peer node will check and delete this node and then propagate this message.
- Parameters
-
◆ deleteNodeNotify() [2/2]
void gossip::server::GossipPeerNode::deleteNodeNotify |
( |
const std::string & |
name, |
|
|
const std::string & |
address, |
|
|
SlotVersion |
version |
|
) |
| |
Async. Send a node delete notify request to connected peer node. Peer node will check and delete this node and then propagate this message.
- Parameters
-
name | The name of deleted node |
address | The address of deleted node |
version | The version of deleted node |
◆ echo()
bool gossip::server::GossipPeerNode::echo |
( |
| ) |
|
Sync. Send a echo request to connected peer node. Message to send is "request,hello", and received should be "echo,hello". If echo succeed, it will update peer node status.
- Returns
- If echo succeed
◆ establishConnection()
std::string gossip::server::GossipPeerNode::establishConnection |
( |
| ) |
|
Sync. Send a connect request to connected peer node. If connection is failed, this class should be released or set unhealthy.
- Returns
- If connection is established, returns {}. Otherwise, returns error information
◆ isAlive()
bool gossip::server::GossipPeerNode::isAlive |
( |
| ) |
const |
|
inline |
Get alive status of peer node. If a rpc is not response, the peer node will be set not alive.
- Returns
- Is peer node alive
◆ name()
std::string gossip::server::GossipPeerNode::name |
( |
| ) |
const |
|
inline |
Get the name of peer node.
- Returns
- The name of peer node
◆ newNodeNotify() [1/2]
Async. Send a new node notify request to connected peer node. Peer node will check and connect to the new node and then propagate this message.
- Parameters
-
◆ newNodeNotify() [2/2]
void gossip::server::GossipPeerNode::newNodeNotify |
( |
const std::string & |
name, |
|
|
const std::string & |
address, |
|
|
SlotVersion |
version |
|
) |
| |
Async. Send a new node notify request to connected peer node. Peer node will check and connect to the new node and then propagate this message.
- Parameters
-
name | The name of new node |
address | The address of new node |
version | The version of new node |
◆ pull()
Async. Send a pull request to connected peer node. The node will check the slot message, if sender has a higher version, it will update slot and then propagate pull request. If pull request is failed because of rpc disconnection, it will retry.
- Parameters
-
origin | Sender's slot information |
◆ receiveResult()
void gossip::server::GossipPeerNode::receiveResult |
( |
| ) |
|
GRPC Asynchronous invocation class.
Handle the async rpc result in daemon thread. If rpc is succeed, the callback of AsyncClientCall will run. Otherwise, the retry function of AsyncClientCall will run.
- Note
- All AsyncClientCall should be deleted in this function.
◆ search()
std::string gossip::server::GossipPeerNode::search |
( |
const std::string & |
key | ) |
|
Search message on peer node. if message is found, returns the owner slot of this message
- Parameters
-
- Returns
- The slot name of message
◆ timestamp()
time_t gossip::server::GossipPeerNode::timestamp |
( |
| ) |
const |
|
inline |
Get last rpc timestamp of peer node.
- Returns
- Last rpc timestamp
◆ version()
SlotVersion gossip::server::GossipPeerNode::version |
( |
| ) |
const |
|
inline |
Get the version of peer node.
- Returns
- The version of peer node
The documentation for this class was generated from the following files:
- /Users/tangrenchu/CLionProjects/Gossip/server/GossipPeerNode.h
- /Users/tangrenchu/CLionProjects/Gossip/server/GossipPeerNode.cpp