Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
swarmio::services::discovery::Service Class Referencefinal

The Discovery Service makes it possible to query remote nodes for services. More...

#include <Service.h>

Inheritance diagram for swarmio::services::discovery::Service:
Inheritance graph
[legend]

Public Member Functions

DiscoveryAwaiter CachedQuery (const Node *node)
 Send a Discovery query to a remote node, or if the information already exists in the cache, return that. More...
 
std::map< const Node *, data::discovery::Response > GetCachedNodeInformation ()
 Returns a map containing all currently valid node information in the cache. More...
 
void GlobalQuery ()
 Sends a global Discovery request. More...
 
void Invalidate ()
 Invalidate the current cached descriptor. More...
 
virtual void NodeDidJoin (const Node *node) noexceptoverride
 Called when a new Node has joined the group. More...
 
virtual void NodeWillLeave (const Node *node) noexceptoverride
 Called when a Node signals that it will leave. More...
 
virtual bool ReceiveMessage (const Node *sender, const data::Message *message) override
 Delivery point of all messages. More...
 
void RegisterDiscoverable (Discoverable *discoverable)
 Register a new Discoverable service. More...
 
void RegisterObserver (Observer *observer)
 Register a new discovery observer. More...
 
 Service (Endpoint *endpoint, bool performActiveDiscovery)
 Construct a new Service object. More...
 
void UnregisterDiscoverable (Discoverable *discoverable)
 Unregister a Discoverable service. More...
 
void UnregisterObserver (Observer *observer)
 Unregister a discovery observer. More...
 
- Public Member Functions inherited from swarmio::Mailbox
virtual void Disconnect ()
 Disconnect this Mailbox from the Endpoint. More...
 
EndpointGetEndpoint ()
 Get the associated Endpoint. More...
 
 Mailbox (const Mailbox &)=delete
 Remove copy constructor. More...
 
virtual void MailboxWasConnected () noexcept
 Called when the mailbox is attached to an already running endpoint or if the attached endpoint has just started. More...
 
virtual void MailboxWillBeDisconnected () noexcept
 Called right before the mailbox is disconnected from its endpoint or if the attached endpoint is about to stop. More...
 
virtual void NodeWasDiscovered (const Node *node) noexcept
 Called when a new Node has been discovered. More...
 
Mailboxoperator= (const Mailbox &)=delete
 Remove assignment operator. More...
 
virtual ~Mailbox ()
 Destroy the Mailbox object. More...
 

Static Public Member Functions

static DiscoveryAwaiter Query (Endpoint *endpoint, const Node *node)
 Send a Discovery query to a remote node. More...
 

Private Member Functions

void CacheDiscoveryResponse (const Node *node, const data::Message *message)
 Handle incoming discovery requests. More...
 
void HandleDiscoveryRequest (const Node *node, const data::Message *message)
 Handle incoming discovery requests. More...
 
void HandleInvalidationRequest (const Node *node, const data::Message *message)
 Invalidate information on a previously discovered node. More...
 

Private Attributes

data::discovery::Response _cachedResponse
 Cached discovery response. More...
 
bool _cacheValid = true
 Tracks whether the current cache is valid. More...
 
std::set< Discoverable * > _discoverables
 List of discoverable services. More...
 
std::mutex _discoverablesMutex
 Mutex to protect discoverable list. More...
 
std::set< Observer * > _observers
 List of discovery observers. More...
 
std::mutex _observersMutex
 Mutex to protect observer list. More...
 
bool _performActiveDiscovery
 Should we send discovery requests automatically? More...
 
std::map< const Node *, data::discovery::Response > _remotes
 Cache of remote node discovery responses. More...
 
std::mutex _remotesMutex
 Mutex to protect remotes list. More...
 

Additional Inherited Members

- Protected Member Functions inherited from swarmio::Mailbox
void FinishConstruction ()
 Called when the last constructor has finished its job. More...
 
void FinishMovingTo (Mailbox *other)
 Called when message handling should be passed onto the new instance. More...
 
 Mailbox ()
 Construct a disconnected Mailbox. More...
 
 Mailbox (Endpoint *endpoint)
 Construct a new Mailbox object. More...
 
 Mailbox (Mailbox &&other)
 Move a Mailbox object. More...
 

Detailed Description

The Discovery Service makes it possible to query remote nodes for services.

Definition at line 18 of file discovery/Service.h.

Constructor & Destructor Documentation

swarmio::services::discovery::Service::Service ( Endpoint endpoint,
bool  performActiveDiscovery 
)
inline

Construct a new Service object.

Parameters
endpointEndpoint
performActiveDiscoverySend automatic discovery requests to newly joined nodes

Definition at line 110 of file discovery/Service.h.

Member Function Documentation

void Service::CacheDiscoveryResponse ( const Node node,
const data::Message *  message 
)
private

Handle incoming discovery requests.

Parameters
senderThe node that has sent the message
messageThe message itself

Definition at line 128 of file discovery/Service.cpp.

DiscoveryAwaiter Service::CachedQuery ( const Node node)

Send a Discovery query to a remote node, or if the information already exists in the cache, return that.

Parameters
nodeRemote node
Returns
DiscoveryAwaiter

Definition at line 233 of file discovery/Service.cpp.

std::map< const Node *, data::discovery::Response > Service::GetCachedNodeInformation ( )

Returns a map containing all currently valid node information in the cache.

Returns
std::map<const Node*, data::discovery::Response>

Definition at line 271 of file discovery/Service.cpp.

void Service::GlobalQuery ( )

Sends a global Discovery request.

Definition at line 258 of file discovery/Service.cpp.

void Service::HandleDiscoveryRequest ( const Node node,
const data::Message *  message 
)
private

Handle incoming discovery requests.

Parameters
senderThe node that has sent the message
messageThe message itself

Definition at line 91 of file discovery/Service.cpp.

void Service::HandleInvalidationRequest ( const Node node,
const data::Message *  message 
)
private

Invalidate information on a previously discovered node.

Parameters
senderThe node that has sent the message
messageThe message itself

Definition at line 150 of file discovery/Service.cpp.

void Service::Invalidate ( )

Invalidate the current cached descriptor.

Definition at line 8 of file discovery/Service.cpp.

void Service::NodeDidJoin ( const Node node)
overridevirtualnoexcept

Called when a new Node has joined the group.

Parameters
nodeThe node that has been discovered

Reimplemented from swarmio::Mailbox.

Definition at line 191 of file discovery/Service.cpp.

void Service::NodeWillLeave ( const Node node)
overridevirtualnoexcept

Called when a Node signals that it will leave.

Parameters
nodeThe node that has left

Reimplemented from swarmio::Mailbox.

Definition at line 178 of file discovery/Service.cpp.

DiscoveryAwaiter Service::Query ( Endpoint endpoint,
const Node node 
)
static

Send a Discovery query to a remote node.

Parameters
nodeRemote node
Returns
DiscoveryAwaiter

Definition at line 211 of file discovery/Service.cpp.

bool Service::ReceiveMessage ( const Node sender,
const data::Message *  message 
)
overridevirtual

Delivery point of all messages.

Parameters
senderThe node that has sent the message
messageThe message itself
Returns
True if the message had been processed and should not be forwarded to other mailboxes

Reimplemented from swarmio::Mailbox.

Definition at line 43 of file discovery/Service.cpp.

void Service::RegisterDiscoverable ( Discoverable discoverable)

Register a new Discoverable service.

Parameters
discoverableService

Definition at line 25 of file discovery/Service.cpp.

void swarmio::services::discovery::Service::RegisterObserver ( Observer observer)
inline

Register a new discovery observer.

Parameters
observerObserver

Definition at line 152 of file discovery/Service.h.

void Service::UnregisterDiscoverable ( Discoverable discoverable)

Unregister a Discoverable service.

Parameters
discoverableService

Definition at line 34 of file discovery/Service.cpp.

void swarmio::services::discovery::Service::UnregisterObserver ( Observer observer)
inline

Unregister a discovery observer.

Parameters
observerObserver

Definition at line 162 of file discovery/Service.h.

Member Data Documentation

data::discovery::Response swarmio::services::discovery::Service::_cachedResponse
private

Cached discovery response.

Definition at line 74 of file discovery/Service.h.

bool swarmio::services::discovery::Service::_cacheValid = true
private

Tracks whether the current cache is valid.

Definition at line 68 of file discovery/Service.h.

std::set<Discoverable*> swarmio::services::discovery::Service::_discoverables
private

List of discoverable services.

Definition at line 56 of file discovery/Service.h.

std::mutex swarmio::services::discovery::Service::_discoverablesMutex
private

Mutex to protect discoverable list.

Definition at line 62 of file discovery/Service.h.

std::set<Observer*> swarmio::services::discovery::Service::_observers
private

List of discovery observers.

Definition at line 44 of file discovery/Service.h.

std::mutex swarmio::services::discovery::Service::_observersMutex
private

Mutex to protect observer list.

Definition at line 50 of file discovery/Service.h.

bool swarmio::services::discovery::Service::_performActiveDiscovery
private

Should we send discovery requests automatically?

Definition at line 26 of file discovery/Service.h.

std::map<const Node*, data::discovery::Response> swarmio::services::discovery::Service::_remotes
private

Cache of remote node discovery responses.

Definition at line 32 of file discovery/Service.h.

std::mutex swarmio::services::discovery::Service::_remotesMutex
private

Mutex to protect remotes list.

Definition at line 38 of file discovery/Service.h.


The documentation for this class was generated from the following files:


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48