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

Telemetry Service can subscribe to receive updates from remote nodes on named values. More...

#include <Service.h>

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

Public Member Functions

virtual void DescribeService (data::discovery::Response &descriptor) override
 Add descriptors for the service to the discovery descriptor. More...
 
data::telemetry::Status GetCachedStatus (const Node *node)
 
virtual bool ReceiveMessage (const Node *sender, const data::Message *message) override
 Delivery point of all messages. More...
 
void RegisterObserver (Observer *observer)
 Register a new status observer. More...
 
void RemoveFieldDefinitionForKey (const std::string &key)
 Remove a field from the schema. More...
 
void RemoveValue (const std::string &key)
 Remove a value from the local telemetry cache. More...
 
 Service (Endpoint *endpoint, std::chrono::milliseconds period=std::chrono::milliseconds(10))
 Construct a new Service object. More...
 
void SetFieldDefinitionForKey (const std::string &key, const data::discovery::Field &field, bool includeInStatus)
 Add field to the schema. More...
 
void SetValue (const std::string &key, const data::Variant &value)
 Add or update a value in the local telemetry cache. More...
 
void UnregisterObserver (Observer *observer)
 Unregister a status 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 NodeDidJoin (const Node *node) noexcept
 Called when a new Node has joined the group. More...
 
virtual void NodeWasDiscovered (const Node *node) noexcept
 Called when a new Node has been discovered. More...
 
virtual void NodeWillLeave (const Node *node) noexcept
 Called when a Node signals that it will leave. More...
 
Mailboxoperator= (const Mailbox &)=delete
 Remove assignment operator. More...
 
virtual ~Mailbox ()
 Destroy the Mailbox object. More...
 

Static Public Member Functions

static UpdateAwaiter Subscribe (Endpoint *endpoint, const Node *node, uint32_t interval=1)
 Subscribe to all named values on the remote node. More...
 
static UpdateAwaiter Subscribe (Endpoint *endpoint, const Node *node, uint32_t interval, const std::list< std::string > &keys)
 Subscribe to soecific named values on the remote node. More...
 

Protected Member Functions

virtual void Update () overridefinal
 Send an update to all subscribers. More...
 
- Protected Member Functions inherited from swarmio::services::PeriodicService
virtual void MailboxWasConnected () noexceptoverride
 Called when the mailbox is attached to an already running endpoint or if the attached endpoint has just started. More...
 
virtual void MailboxWillBeDisconnected () noexceptoverride
 Called right before the mailbox is disconnected from its endpoint or if the attached endpoint is about to stop. More...
 
 PeriodicService (Endpoint *endpoint, std::chrono::milliseconds period)
 Construct a new Periodic Service object. More...
 
- 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...
 

Private Attributes

std::set< Observer * > _observers
 List of observers. More...
 
std::shared_timed_mutex _observersMutex
 Mutex to protect the list of observers. More...
 
std::map< const Node *, data::telemetry::Status > _reports
 Cached values for remote status reports. More...
 
std::shared_timed_mutex _reportsMutex
 Mutex to protect remote status reports. More...
 
data::discovery::Schema _schema
 Schema. More...
 
std::shared_timed_mutex _schemaMutex
 Mutex to protect the schema. More...
 
std::set< std::string > _statusKeys
 List of keys to include in the status broadcast. More...
 
std::list< Tracker_trackers
 Trackers for each remote subscription. More...
 
std::shared_timed_mutex _trackersMutex
 Mutex to protect the list of trackers. More...
 
std::map< std::string, data::Variant > _values
 List of published telemetry values. More...
 
std::shared_timed_mutex _valuesMutex
 Mutex to protect the map of values. More...
 

Detailed Description

Telemetry Service can subscribe to receive updates from remote nodes on named values.

Definition at line 21 of file telemetry/Service.h.

Constructor & Destructor Documentation

swarmio::services::telemetry::Service::Service ( Endpoint endpoint,
std::chrono::milliseconds  period = std::chrono::milliseconds(10) 
)
inline

Construct a new Service object.

Parameters
endpointEndpoint
periodTick period

Definition at line 132 of file telemetry/Service.h.

Member Function Documentation

void Service::DescribeService ( data::discovery::Response &  descriptor)
overridevirtual

Add descriptors for the service to the discovery descriptor.

Parameters
descriptorThe proposed response to load the description into

Implements swarmio::services::discovery::Discoverable.

Definition at line 212 of file telemetry/Service.cpp.

data::telemetry::Status swarmio::services::telemetry::Service::GetCachedStatus ( const Node node)
inline

Definition at line 215 of file telemetry/Service.h.

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 150 of file telemetry/Service.cpp.

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

Register a new status observer.

Parameters
observerObserver

Definition at line 198 of file telemetry/Service.h.

void swarmio::services::telemetry::Service::RemoveFieldDefinitionForKey ( const std::string &  key)
inline

Remove a field from the schema.

Parameters
keyKey

Definition at line 186 of file telemetry/Service.h.

void swarmio::services::telemetry::Service::RemoveValue ( const std::string &  key)
inline

Remove a value from the local telemetry cache.

Parameters
keyKey

Definition at line 155 of file telemetry/Service.h.

void swarmio::services::telemetry::Service::SetFieldDefinitionForKey ( const std::string &  key,
const data::discovery::Field &  field,
bool  includeInStatus 
)
inline

Add field to the schema.

Parameters
keyKey
fieldField

Definition at line 167 of file telemetry/Service.h.

void swarmio::services::telemetry::Service::SetValue ( const std::string &  key,
const data::Variant &  value 
)
inline

Add or update a value in the local telemetry cache.

Parameters
keyKey
valueValue

Definition at line 144 of file telemetry/Service.h.

static UpdateAwaiter swarmio::services::telemetry::Service::Subscribe ( Endpoint endpoint,
const Node node,
uint32_t  interval = 1 
)
inlinestatic

Subscribe to all named values on the remote node.

Parameters
endpointEndpoint to use
nodeRemote node
intervalInterval
Returns
UpdateAwaiter Awaiter for the updates

Definition at line 109 of file telemetry/Service.h.

UpdateAwaiter Service::Subscribe ( Endpoint endpoint,
const Node node,
uint32_t  interval,
const std::list< std::string > &  keys 
)
static

Subscribe to soecific named values on the remote node.

Parameters
endpointEndpoint to use
nodeRemote node
intervalInterval
keysKeys to subscribe to
Returns
UpdateAwaiter Awaiter for the updates

Definition at line 11 of file telemetry/Service.cpp.

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

Unregister a status observer.

Parameters
observerObserver

Definition at line 209 of file telemetry/Service.h.

void Service::Update ( )
finaloverrideprotectedvirtual

Send an update to all subscribers.

Implements swarmio::services::PeriodicService.

Definition at line 38 of file telemetry/Service.cpp.

Member Data Documentation

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

List of observers.

Definition at line 71 of file telemetry/Service.h.

std::shared_timed_mutex swarmio::services::telemetry::Service::_observersMutex
private

Mutex to protect the list of observers.

Definition at line 77 of file telemetry/Service.h.

std::map<const Node*, data::telemetry::Status> swarmio::services::telemetry::Service::_reports
private

Cached values for remote status reports.

Definition at line 83 of file telemetry/Service.h.

std::shared_timed_mutex swarmio::services::telemetry::Service::_reportsMutex
private

Mutex to protect remote status reports.

Definition at line 89 of file telemetry/Service.h.

data::discovery::Schema swarmio::services::telemetry::Service::_schema
private

Schema.

Definition at line 41 of file telemetry/Service.h.

std::shared_timed_mutex swarmio::services::telemetry::Service::_schemaMutex
private

Mutex to protect the schema.

Definition at line 53 of file telemetry/Service.h.

std::set<std::string> swarmio::services::telemetry::Service::_statusKeys
private

List of keys to include in the status broadcast.

Definition at line 47 of file telemetry/Service.h.

std::list<Tracker> swarmio::services::telemetry::Service::_trackers
private

Trackers for each remote subscription.

Definition at line 59 of file telemetry/Service.h.

std::shared_timed_mutex swarmio::services::telemetry::Service::_trackersMutex
private

Mutex to protect the list of trackers.

Definition at line 65 of file telemetry/Service.h.

std::map<std::string, data::Variant> swarmio::services::telemetry::Service::_values
private

List of published telemetry values.

Definition at line 29 of file telemetry/Service.h.

std::shared_timed_mutex swarmio::services::telemetry::Service::_valuesMutex
private

Mutex to protect the map of values.

Definition at line 35 of file telemetry/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