Notification Enum
TheNotification enum represents all possible notification types that can be emitted by a TAPLE node.
Emitted when a new subject has been created in the ledger.Fields:
subject_id(String): The unique identifier of the newly created subject
Emitted when a new event has been successfully added to a subject’s chain.Fields:
sn(u64): The sequence number of the new eventsubject_id(String): The unique identifier of the subject
Emitted when a subject’s state has been synchronized or updated.Fields:
sn(u64): The sequence number of the event that updated the statesubject_id(String): The unique identifier of the subject
Emitted when an approval request has been received and is pending a response.Fields:
id(String): The unique identifier of the approval requestsubject_id(String): The unique identifier of the subject requiring approvalsn(u64): The sequence number of the event pending approval
Emitted when an approval request has become obsolete, either because the governance version changed or the event was confirmed without the approval.Fields:
id(String): The unique identifier of the obsoleted approval requestsubject_id(String): The unique identifier of the subjectsn(u64): The sequence number of the obsoleted event
Emitted when an unrecoverable error occurs in the node.Fields:
error(String): A description of the error that occurred
Receiving Notifications
All notifications must be consumed to prevent blocking the node. If the notification buffer is full, the node will block until space becomes available. The TAPLE node provides multiple methods for handling notifications.Method 1: Receive Individual Notifications
Userecv_notification() to consume notifications one by one while maintaining control of the execution flow:
Method 2: Handle All Notifications
Usehandle_notifications() to process all notifications with a custom handler function. This method blocks until the shutdown signal is received:
Method 3: Drop All Notifications
Usedrop_notifications() when you don’t need to process notifications:
Complete Example
Here’s a complete example showing how to create a governance subject and handle the resulting notifications:Buffer Size
The notification channel has a buffer size of 1000 messages. If this buffer fills up, the node will block until notifications are consumed. Make sure to process notifications regularly to prevent blocking.Thread Safety
The notification receiver (mpsc::Receiver<Notification>) is thread-safe and can be moved across async tasks. However, only one task can receive notifications at a time.