A client connecting to a gossip node.
More...
#include <GossipClient.h>
A client connecting to a gossip node.
Class GossipClient is the user client of GossipNode. Users can use this class to send CRUD request or gossip status command to a GossipNode Impl.
◆ GossipClient()
gossip::client::GossipClient::GossipClient |
( |
std::string |
address, |
|
|
std::string |
token |
|
) |
| |
|
explicit |
Constructor of GossipClient.
- Parameters
-
address | Ip address of gossip node to connect |
token | Token to connect to gossip node |
◆ connectToNode()
GossipClient::Result< bool > gossip::client::GossipClient::connectToNode |
( |
const std::string & |
address | ) |
|
Send a command to connected node that make it connects to another node with assigned address. This operation can connect two gossip cluster.
- Parameters
-
address | The address of node to connect |
- Returns
- Connection result
◆ deleteMessage()
Delete a message by key. This operation will only delete message in local slot.
- Parameters
-
- Returns
- Delete result
◆ getMessage()
GossipClient::Result< std::string > gossip::client::GossipClient::getMessage |
( |
const std::string & |
key | ) |
|
Get the value of message by key. This operation will only search local slot.
- Parameters
-
- Returns
- Search result
- Note
- Use getMessageFromAllNode if you want to search message from all gossip nodes.
◆ getMessageFromAllNode()
Get the value of message by key. This operation will start search operation in all slots. If param latest is set true, this operation will get latest version of value.
- Parameters
-
key | The key of message |
latest | If latest version is needed |
- Returns
- Search result
- Note
- If latest is set false, this operation will only search on connected node. This means message may be not newest.
◆ getNodeStatus()
Send a command to connected node to get its current status, which contains node's name, address, memory use and peer nodes' information.
- Returns
- Node status of Json type.
◆ insertOrUpdateMessage()
GossipClient::Result< bool > gossip::client::GossipClient::insertOrUpdateMessage |
( |
const std::string & |
key, |
|
|
const std::string & |
value |
|
) |
| |
Insert or update a message to connected gossip node. The message will use arrived time as version, so this operation will not fail because of version check.
- Parameters
-
key | The key of message |
value | The value of message |
- Returns
- Insert result
◆ peerAddress()
std::string gossip::client::GossipClient::peerAddress |
( |
| ) |
const |
|
inline |
Get the ip address of connected gossip node.
- Returns
- Ip address of gossip node
◆ shutdown()
Send a command to connected node that make it quit.
- Returns
- Shutdown result
The documentation for this class was generated from the following files:
- /Users/tangrenchu/CLionProjects/Gossip/client/GossipClient.h
- /Users/tangrenchu/CLionProjects/Gossip/client/GossipClient.cpp