risingwave_connector::sink::writer

Trait FormattedSink

source
pub trait FormattedSink {
    type K;
    type V;

    // Required method
    async fn write_one(
        &mut self,
        k: Option<Self::K>,
        v: Option<Self::V>,
    ) -> Result<()>;

    // Provided method
    async fn write_chunk<F: SinkFormatter>(
        &mut self,
        chunk: StreamChunk,
        formatter: &F,
    ) -> Result<()>
       where F::K: SerTo<Self::K>,
             F::V: SerTo<Self::V> { ... }
}
Expand description

A free-form sink that may output in multiple formats and encodings. Examples include kafka, kinesis, nats and redis.

The implementor specifies required key & value type (likely string or bytes), as well as how to write a single pair. The provided write_chunk method would handle the interaction with a SinkFormatter.

Currently kafka takes &mut self while kinesis takes &self. So we use &mut self in trait but implement it for &Kinesis. This allows us to hold &mut &Kinesis and &Kinesis simultaneously, preventing the schema clone issue propagating from kafka to kinesis.

Required Associated Types§

source

type K

source

type V

Required Methods§

source

async fn write_one( &mut self, k: Option<Self::K>, v: Option<Self::V>, ) -> Result<()>

Provided Methods§

source

async fn write_chunk<F: SinkFormatter>( &mut self, chunk: StreamChunk, formatter: &F, ) -> Result<()>
where F::K: SerTo<Self::K>, F::V: SerTo<Self::V>,

Object Safety§

This trait is not object safe.

Implementors§