Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Publisher< T > Class Template Referenceabstract

#include <publisher.h>

Inheritance diagram for Publisher< T >:
Inheritance graph
[legend]

Public Member Functions

virtual void addPublisherStateListener (const std::function< void(const PublisherState &)> &listener)
 
Aws::DataFlow::UploadStatus attemptPublish (T &data) override
 
bool canPublish ()
 
std::chrono::milliseconds getLastPublishDuration ()
 
int getPublishAttempts ()
 
PublisherState getPublisherState ()
 
int getPublishSuccesses ()
 
float getPublishSuccessPercentage ()
 
 Publisher ()
 
bool shutdown () override
 
 ~Publisher () override=default
 
- Public Member Functions inherited from Service
ServiceState getState ()
 
virtual std::string getStatusString ()
 
 Service ()
 
virtual bool start ()
 
virtual ~Service ()=default
 

Protected Member Functions

virtual Aws::DataFlow::UploadStatus publishData (T &data)=0
 
- Protected Member Functions inherited from Service
void setState (ServiceState new_state)
 

Private Attributes

std::atomic< std::chrono::milliseconds > last_publish_duration_ {}
 
std::atomic< int > publish_attempts_ {}
 
std::mutex publish_mutex_
 
std::atomic< int > publish_successes_ {}
 
ObservableObject< PublisherStatepublisher_state_
 

Detailed Description

template<typename T>
class Publisher< T >

Base class implementing the Aws::FileManagement::IPublisher interface.

Overriding classes should provide the mechanisms to initialize / configure their respective components.

Template Parameters
Tthe type to publish

Definition at line 46 of file publisher.h.

Constructor & Destructor Documentation

template<typename T>
Publisher< T >::Publisher ( )
inline

Definition at line 51 of file publisher.h.

template<typename T>
Publisher< T >::~Publisher ( )
overridedefault

Member Function Documentation

template<typename T>
virtual void Publisher< T >::addPublisherStateListener ( const std::function< void(const PublisherState &)> &  listener)
inlinevirtual

Provide the registration mechanism for ObservableObject (in this case PublisherState) changes.

Parameters
listenerthe PublisherState listener
Returns
true if the listener was added, false otherwise

Definition at line 172 of file publisher.h.

template<typename T>
Aws::DataFlow::UploadStatus Publisher< T >::attemptPublish ( T &  data)
inlineoverridevirtual

Attempt to publish data to CloudWatch if this service is in the started state.

Parameters
datathe data to publish
Returns
the resulting Aws::DataFlow::UploadStatus from the publish attempt. Returns FAIL if not in the started state.

Implements Aws::DataFlow::IPublisher< T >.

Definition at line 75 of file publisher.h.

template<typename T>
bool Publisher< T >::canPublish ( )
inline

Return true if this publisher can send data to CloudWatch, false otherwise.

Returns

Definition at line 121 of file publisher.h.

template<typename T>
std::chrono::milliseconds Publisher< T >::getLastPublishDuration ( )
inline

Return the time taken for the last publish attempt

Returns
std::chrono::milliseconds the last publish attempt duration

Definition at line 147 of file publisher.h.

template<typename T>
int Publisher< T >::getPublishAttempts ( )
inline

Return the number of attempts made to publish

Returns

Definition at line 138 of file publisher.h.

template<typename T>
PublisherState Publisher< T >::getPublisherState ( )
inline

Return the current state of the publisher.

Returns

Definition at line 64 of file publisher.h.

template<typename T>
int Publisher< T >::getPublishSuccesses ( )
inline

Return the number of publish successes

Returns

Definition at line 130 of file publisher.h.

template<typename T>
float Publisher< T >::getPublishSuccessPercentage ( )
inline

Calculate and return the success rate of this publisher.

Returns
the number of successes divided by the number of attempts. If zero attempts have been made then return 0.

Definition at line 157 of file publisher.h.

template<typename T>
virtual Aws::DataFlow::UploadStatus Publisher< T >::publishData ( T &  data)
protectedpure virtual

Actual publishing mechanism implemented by the agent.

Parameters
data
Returns
the Aws::DataFlow::UploadStatus resulting from the implemented attempt

Implemented in SimpleTestPublisher.

template<typename T>
bool Publisher< T >::shutdown ( )
inlineoverridevirtual

Shutdown the publisher. This waits for attemptPublish to finish before returning.

Returns
the result of shutdown

Reimplemented from Service.

Definition at line 108 of file publisher.h.

Member Data Documentation

template<typename T>
std::atomic<std::chrono::milliseconds> Publisher< T >::last_publish_duration_ {}
private

The amount of time taken for the last publish action

Definition at line 202 of file publisher.h.

template<typename T>
std::atomic<int> Publisher< T >::publish_attempts_ {}
private

Number of publish attempts

Definition at line 198 of file publisher.h.

template<typename T>
std::mutex Publisher< T >::publish_mutex_
mutableprivate

Mutex used in publish and shutdown

Definition at line 206 of file publisher.h.

template<typename T>
std::atomic<int> Publisher< T >::publish_successes_ {}
private

Number of publish successes

Definition at line 194 of file publisher.h.

template<typename T>
ObservableObject<PublisherState> Publisher< T >::publisher_state_
private

Track the publish state in a thread safe container which can provide events to registered listeners.

Definition at line 190 of file publisher.h.


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


dataflow_lite
Author(s): AWS RoboMaker
autogenerated on Fri May 7 2021 02:18:22