Gossip 1.1
Classes | Public Member Functions | List of all members
gossip::client::GossipClient Class Reference

A client connecting to a gossip node. More...

#include <GossipClient.h>

Classes

class  Result
 Wrapper return value. More...
 

Public Member Functions

 GossipClient (std::string address, std::string token)
 
Result< bool > insertOrUpdateMessage (const std::string &key, const std::string &value)
 
Result< std::string > getMessage (const std::string &key)
 
Result< pf_gossip::SearchResultgetMessageFromAllNode (const std::string &key, bool latest=false)
 
Result< bool > deleteMessage (const std::string &key)
 
Result< bool > connectToNode (const std::string &address)
 
Result< bool > shutdown ()
 
Result< nlohmann::json > getNodeStatus ()
 
std::string peerAddress () const
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GossipClient()

gossip::client::GossipClient::GossipClient ( std::string  address,
std::string  token 
)
explicit

Constructor of GossipClient.

Parameters
addressIp address of gossip node to connect
tokenToken to connect to gossip node

Member Function Documentation

◆ 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
addressThe address of node to connect
Returns
Connection result

◆ deleteMessage()

GossipClient::Result< bool > gossip::client::GossipClient::deleteMessage ( const std::string &  key)

Delete a message by key. This operation will only delete message in local slot.

Parameters
keyThe key of message
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
keyThe key of message
Returns
Search result
Note
Use getMessageFromAllNode if you want to search message from all gossip nodes.

◆ getMessageFromAllNode()

GossipClient::Result< pf_gossip::SearchResult > gossip::client::GossipClient::getMessageFromAllNode ( const std::string &  key,
bool  latest = false 
)

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
keyThe key of message
latestIf 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()

GossipClient::Result< nlohmann::json > gossip::client::GossipClient::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
keyThe key of message
valueThe 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()

GossipClient::Result< bool > gossip::client::GossipClient::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: