pub trait InputConnector {
    fn run<'async_trait>(
        self: Box<Self>,
        sender: Sender
    ) -> Pin<Box<dyn Future<Output = Result<(), ClosedChannel>> + Send + 'async_trait>>
   where
        Self: 'async_trait
; }
Expand description

Implement an input connector. An input connector is in change of creating Message and sending asynchronously to the services.

If the sender return a ClosedChannel error, it is expected to propagate this error.

See default implementations in connectors

Do not forget to add the async_trait crate when implement this trait

Example

use service_io::interface::{InputConnector};
use service_io::channel::{ClosedChannel, Sender};
use service_io::message::{Message};

use async_trait::async_trait;

struct MyInput;

#[async_trait]
impl InputConnector for MyInput {
    async fn run(self: Box<Self>, sender: Sender) -> Result<(), ClosedChannel> {
         // Load phase
         // ...
         loop {
             // Get the message from your implementation
             // ...
             let message = Message::default();

             // Send the message to the service
             sender.send(message).await?;
         }
    }
}

Required Methods

Implementations on Foreign Types

Implementors