Skip to main content

Service

Trait Service 

Source
pub trait Service {
    // Required methods
    fn on_ready(&mut self, endpoint: &EndpointHandle);
    fn on_waiting_for_configuration(&mut self, endpoint: &EndpointHandle);
    fn on_configuration(
        &mut self,
        endpoint: &EndpointHandle,
        message: Box<Delivery>,
    ) -> Result<bool, Error>;
    fn on_event(
        &mut self,
        endpoint: &EndpointHandle,
        message: Box<Delivery>,
    ) -> Result<(), Error>;
    fn on_command(
        &mut self,
        endpoint: &EndpointHandle,
        message: Box<Delivery>,
    ) -> Result<(), Error>;
    fn on_result(
        &mut self,
        endpoint: &EndpointHandle,
        message: Box<Delivery>,
    ) -> Result<(), Error>;
    fn on_message_returned(
        &mut self,
        endpoint: &EndpointHandle,
        routing_key: String,
    );
    fn on_clock_ticked(&mut self, endpoint: &EndpointHandle, time: u64);
}
Expand description

The traditional Callback API

A service should be run with run_service.

Required Methods§

Source

fn on_ready(&mut self, endpoint: &EndpointHandle)

Called when the EndpointHandle starts consuming the subscribed messages.

Source

fn on_waiting_for_configuration(&mut self, endpoint: &EndpointHandle)

Called when the EndpointHandle is connected and Configuration events were subscribed.

Usually, the implementation publishes a configuration request event on the EDA Bus.

Source

fn on_configuration( &mut self, endpoint: &EndpointHandle, message: Box<Delivery>, ) -> Result<bool, Error>

Called when a subscribed configuration event is received.

The implementation returns Ok(true) only if it is fully configured and ready to consume business events.

Source

fn on_event( &mut self, endpoint: &EndpointHandle, message: Box<Delivery>, ) -> Result<(), Error>

Called when a subscribed event is received.

If an Error is returned, the message is acknowledged accordingly.

Source

fn on_command( &mut self, endpoint: &EndpointHandle, message: Box<Delivery>, ) -> Result<(), Error>

Called when a subscribed command is received.

If an Error is returned, the message is acknowledged accordingly.

Source

fn on_result( &mut self, endpoint: &EndpointHandle, message: Box<Delivery>, ) -> Result<(), Error>

Called when a subscribed result is received.

If an Error is returned, the message is acknowledged accordingly.

Source

fn on_message_returned( &mut self, endpoint: &EndpointHandle, routing_key: String, )

Called when a message sent with the mandatory flag true is unroutable.

Source

fn on_clock_ticked(&mut self, endpoint: &EndpointHandle, time: u64)

This method is called every second with the time elapsed seconds since the endpoint was started.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§