The Discovery Service makes it possible to query remote nodes for services. More...
#include <Service.h>

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... | |
| Endpoint * | GetEndpoint () |
| 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... | |
| Mailbox & | operator= (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... | |
The Discovery Service makes it possible to query remote nodes for services.
Definition at line 18 of file discovery/Service.h.
|
inline |
Construct a new Service object.
| endpoint | Endpoint |
| performActiveDiscovery | Send automatic discovery requests to newly joined nodes |
Definition at line 110 of file discovery/Service.h.
|
private |
Handle incoming discovery requests.
| sender | The node that has sent the message |
| message | The 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.
| node | Remote node |
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.
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.
|
private |
Handle incoming discovery requests.
| sender | The node that has sent the message |
| message | The message itself |
Definition at line 91 of file discovery/Service.cpp.
|
private |
Invalidate information on a previously discovered node.
| sender | The node that has sent the message |
| message | The 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.
|
overridevirtualnoexcept |
Called when a new Node has joined the group.
| node | The node that has been discovered |
Reimplemented from swarmio::Mailbox.
Definition at line 191 of file discovery/Service.cpp.
|
overridevirtualnoexcept |
Called when a Node signals that it will leave.
| node | The node that has left |
Reimplemented from swarmio::Mailbox.
Definition at line 178 of file discovery/Service.cpp.
|
static |
Send a Discovery query to a remote node.
| node | Remote node |
Definition at line 211 of file discovery/Service.cpp.
|
overridevirtual |
Delivery point of all messages.
| sender | The node that has sent the message |
| message | The message itself |
Reimplemented from swarmio::Mailbox.
Definition at line 43 of file discovery/Service.cpp.
| void Service::RegisterDiscoverable | ( | Discoverable * | discoverable | ) |
Register a new Discoverable service.
| discoverable | Service |
Definition at line 25 of file discovery/Service.cpp.
|
inline |
Register a new discovery observer.
| observer | Observer |
Definition at line 152 of file discovery/Service.h.
| void Service::UnregisterDiscoverable | ( | Discoverable * | discoverable | ) |
Unregister a Discoverable service.
| discoverable | Service |
Definition at line 34 of file discovery/Service.cpp.
|
inline |
Unregister a discovery observer.
| observer | Observer |
Definition at line 162 of file discovery/Service.h.
|
private |
Cached discovery response.
Definition at line 74 of file discovery/Service.h.
|
private |
Tracks whether the current cache is valid.
Definition at line 68 of file discovery/Service.h.
|
private |
List of discoverable services.
Definition at line 56 of file discovery/Service.h.
|
private |
Mutex to protect discoverable list.
Definition at line 62 of file discovery/Service.h.
List of discovery observers.
Definition at line 44 of file discovery/Service.h.
|
private |
Mutex to protect observer list.
Definition at line 50 of file discovery/Service.h.
|
private |
Should we send discovery requests automatically?
Definition at line 26 of file discovery/Service.h.
|
private |
Cache of remote node discovery responses.
Definition at line 32 of file discovery/Service.h.
|
private |
Mutex to protect remotes list.
Definition at line 38 of file discovery/Service.h.