Skip to main content

MessageConsumer

Trait MessageConsumer 

Source
pub trait MessageConsumer: Send + Sync {
    // Required methods
    fn connector_name(&self) -> &'static str;
    fn receive<'life0, 'life1, 'async_trait>(
        &'life0 self,
        calls: &'life1 CallSlot,
        max: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<InboundMessage>, FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn ack<'life0, 'life1, 'async_trait>(
        &'life0 self,
        calls: &'life1 CallSlot,
        tokens: Vec<AckToken>,
    ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn decode(&self, message: &InboundMessage) -> Result<Value, FaucetError>;

    // Provided methods
    fn config_schema(&self) -> Value { ... }
    fn dataset_uri(&self) -> String { ... }
    fn call_context(&self) -> CallContext { ... }
    fn max_messages(&self) -> Option<usize> { ... }
    fn idle_receives_to_stop(&self) -> u32 { ... }
    fn check<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        calls: &'life1 CallSlot,
        ctx: &'life2 CheckContext,
    ) -> Pin<Box<dyn Future<Output = Result<Option<CheckReport>, FaucetError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

A consumer’s primitives (RFC 0014). Wrap it in a MessageSourceDriver, then a DriverSource.

Required Methods§

Source

fn connector_name(&self) -> &'static str

The connector’s name.

Source

fn receive<'life0, 'life1, 'async_trait>( &'life0 self, calls: &'life1 CallSlot, max: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<InboundMessage>, FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Receive up to max messages, waiting at most the consumer’s own idle wait. An empty result means nothing arrived in that wait.

Source

fn ack<'life0, 'life1, 'async_trait>( &'life0 self, calls: &'life1 CallSlot, tokens: Vec<AckToken>, ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Acknowledge messages so the broker does not redeliver them.

Source

fn decode(&self, message: &InboundMessage) -> Result<Value, FaucetError>

The record for a received message.

Provided Methods§

Source

fn config_schema(&self) -> Value

The JSON Schema of the connector’s config.

Source

fn dataset_uri(&self) -> String

The source, for lineage (credential-free).

Source

fn call_context(&self) -> CallContext

The connector’s own call defaults.

Source

fn max_messages(&self) -> Option<usize>

Stop after this many messages; None: only idleness stops the read.

Source

fn idle_receives_to_stop(&self) -> u32

Consecutive empty receives that end the read.

Source

fn check<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, calls: &'life1 CallSlot, ctx: &'life2 CheckContext, ) -> Pin<Box<dyn Future<Output = Result<Option<CheckReport>, FaucetError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

A preflight probe that consumes nothing (connect, look up the queue). None (the default): the probe is skipped, because reading a page would take messages off the queue.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§