Skip to main content

Sink

Trait Sink 

Source
pub trait Sink: Send + Sync {
    // Required method
    fn write_batch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        records: &'life1 [Value],
    ) -> Pin<Box<dyn Future<Output = Result<usize, FaucetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn flush<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn write_batch_partial<'life0, 'life1, 'async_trait>(
        &'life0 self,
        records: &'life1 [Value],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(), FaucetError>>, FaucetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn config_schema(&self) -> Value { ... }
    fn connector_name(&self) -> &'static str { ... }
    fn check<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _ctx: &'life1 CheckContext,
    ) -> Pin<Box<dyn Future<Output = Result<CheckReport, FaucetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

A sink writes records to an external system.

Required Methods§

Source

fn write_batch<'life0, 'life1, 'async_trait>( &'life0 self, records: &'life1 [Value], ) -> Pin<Box<dyn Future<Output = Result<usize, FaucetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Write a batch of records to the destination.

Returns the number of records successfully written.

Provided Methods§

Source

fn flush<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), FaucetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Flush any buffered data to the destination.

The default implementation is a no-op (suitable for sinks that write immediately in write_batch).

Source

fn write_batch_partial<'life0, 'life1, 'async_trait>( &'life0 self, records: &'life1 [Value], ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(), FaucetError>>, FaucetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Write a batch and report per-row outcomes.

Sinks whose underlying API exposes per-row results (BigQuery insertAll, Elasticsearch _bulk) override this. The default implementation delegates to Self::write_batch and maps a single success onto a uniform all-Ok(()) vector. An outer failure is bubbled up unchanged so the pipeline’s DLQ router can apply its on_batch_error policy at a single decision point.

Source

fn config_schema(&self) -> Value

Return a JSON Schema describing the configuration this sink accepts.

The schema is auto-generated from the config struct using schemars. Callers can inspect it to discover required fields, types, defaults, and descriptions before constructing the sink.

The default returns an empty object schema.

Source

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

Stable identifier used as the connector label on metrics and the connector attribute on spans. See Source::connector_name.

Source

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

Run a fast, non-mutating preflight probe (used by faucet doctor).

Unlike sources, a sink has no non-mutating “first page” equivalent (write_batch mutates the destination), so the default returns CheckReport::not_implemented. Built-in sinks override this with a connect / auth / metadata probe.

The probe MUST be idempotent and side-effect-free — no inserts, no residual rows or objects — and must never put credentials or connection strings in a probe reason/hint.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<'a, S> Sink for InstrumentedSink<'a, S>
where S: Sink + ?Sized,