CloudEvent
Publish status - CloudEvent
status - CloudEvent
| Constant | Description | Accessibility |
|---|---|---|
Status::NEW |
Initial status of a newly created or received event | Reading and writing |
Status::SENDING |
The event is being sent to the cloud | Reading |
Status::SENT |
The event was successfully sent to the cloud | Reading and writing |
Status::FAILED |
Recoverable error occurred while creating the event or sending it to the cloud | Reading and writing |
Status::INVALID |
Irrecoverable error occurred while creating the event. | Not accessible |
Status::FAILED indicates a recoverable error. The failed operation with the event can be retried when the condition that caused the error is resolved.
For Status::FAILED and Status::INVALID the error() method can be used to find more information about the reason.
isNew - CloudEvent
Shorthand for event.status() == CloudEvent::NEW. This is the initial status of a newly created or received event
// PROTOTYPE
bool isNew() const
isSending - CloudEvent
Shorthand for event.status() == CloudEvent::SENDING. The event is being sent to the cloud.
// PROTOTYPE
bool isSending() const
isSent - CloudEvent
Shorthand for event.status() == CloudEvent::SENT. The event was successfully sent to the cloud.
// PROTOTYPE
bool isSent() const
isOk - CloudEvent
Returns true if the event status is something other than Status::FAILED or Status::INVALID.
// PROTOTYPE
bool isOk() const
isValid - CloudEvent
Returns true if the event status is not Status::INVALID. Note that this is different than isOk().
// PROTOTYPE
bool isValid() const
error - CloudEvent
Returns a 0 if the event is not in a failed or invalid state, otherwise a system error code defined Error::Type, which is a negative value.
// PROTOTYPE
int error() const;
See system errors for the available error codes.
cancel - CloudEvent
Cancel sending the event.
This method has no effect if the event is not currently being sent to the Cloud.
A cancelled event is invalidated and cannot be published again.
// PROTOTYPE
void cancel();
resetStatus - CloudEvent
Reset the status of the event.
This method resets the status of the event back to NEW if the current status is SENT or FAILED. Otherwise, it has no effect.
It is normally not necessary to call this method before publishing a failed event again.
// PROTOTYPE
void resetStatus();
clear - CloudEvent
Clear and reinitialize the event instance.
// PROTOTYPE
void clear();
// EXAMPLE
// These two statements are equivalent
event.clear();
event = CloudEvent();
onStatusChange - CloudEvent
Set a callback to be invoked when the status of the event changes.
For an example, see Simple publish callback.
// PROTOTYPE
CloudEvent& onStatusChange(std::function<OnStatusChange> callback);
// Handler definition
typedef void OnStatusChange(CloudEvent event);
// Handler prototype
void myStatusChangeHandler(CloudEvent event)
canPublish - CloudEvent
Check if an event with a given size would be within the limit for the amount of event data in flight once it's attempted to be published.
- size Size of the event data.
- Returns
trueif the event can be published, otherwisefalse.
For an example, see State machine class publish.
// PROTOTYPE
static bool canPublish(size_t size);