Struct taple_core::Node
source · pub struct Node<M: DatabaseManager<C>, C: DatabaseCollection> { /* private fields */ }
Expand description
Structure representing a TAPLE node
A node must be instantiated using the [Taple::build
] method, which requires a set
of configuration parameters in order to be properly initialized.
Implementations§
source§impl<M: DatabaseManager<C> + 'static, C: DatabaseCollection + 'static> Node<M, C>
impl<M: DatabaseManager<C> + 'static, C: DatabaseCollection + 'static> Node<M, C>
sourcepub fn build(settings: Settings, database: M) -> Result<(Self, Api), Error>
pub fn build(settings: Settings, database: M) -> Result<(Self, Api), Error>
This method creates and initializes a TAPLE node.
Possible results
If the process is successful, the method will return Ok(())
.
An error will be returned only if it has not been possible to generate the necessary data
for the initialization of the components, mainly due to problems in the initial configuration.
Panics
This method panics if it has not been possible to generate the network layer.
sourcepub async fn recv_notification(&mut self) -> Option<Notification>
pub async fn recv_notification(&mut self) -> Option<Notification>
Receive a single notification
All notifications must be consumed. If the notification buffer is full the node will be blocked until there is space in the buffer. Notifications can be consumed in different ways.
recv_notification
allows to consume the notifications one by one and keep control
of the execution flow.
sourcepub async fn handle_notifications<H>(self, handler: H)where
H: Fn(Notification),
pub async fn handle_notifications<H>(self, handler: H)where H: Fn(Notification),
Handle all notifications
All notifications must be consumed. If the notification buffer is full the node will be blocked until there is space in the buffer. Notifications can be consumed in different ways.
handle_notifications
processes all notifications from the node. For this purpose,
the function in charge of processing the notifications is passed as input. This
function blocks the task where it is invoked until the shutdown signal is produced.
sourcepub async fn drop_notifications(self)
pub async fn drop_notifications(self)
Drop all notifications
All notifications must be consumed. If the notification buffer is full the node will be blocked until there is space in the buffer. Notifications can be consumed in different ways.
drop_notifications
discards all notifications from the node.
sourcepub fn bind_with_shutdown(
&self,
signal: impl Future<Output = ()> + Send + 'static
)
pub fn bind_with_shutdown( &self, signal: impl Future<Output = ()> + Send + 'static )
Bind the node with a shutdown signal.
When the signal completes, the server will start the graceful shutdown process. The node can be bind to multiple signals.
sourcepub async fn shutdown_gracefully(self)
pub async fn shutdown_gracefully(self)
Shutdown gracefully the node
This function triggers the shutdown signal and waits until the node is safely terminated. This function can only be used if Y or Z has not been used to process the notifications.