SinkFactory

Trait SinkFactory 

Source
pub trait SinkFactory:
    SinkDefProvider
    + Send
    + Sync
    + 'static {
    // Required methods
    fn kind(&self) -> &'static str;
    fn build<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        spec: &'life1 ResolvedSinkSpec,
        ctx: &'life2 SinkBuildCtx,
    ) -> Pin<Box<dyn Future<Output = SinkResult<SinkHandle>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn validate_spec(&self, _spec: &ResolvedSinkSpec) -> SinkResult<()> { ... }
}
Expand description

Factory trait for creating sink instances.

Implementors must also implement SinkDefProvider to provide connector metadata. The orchestrator uses this trait to construct sinks at runtime based on resolved specifications.

§Example

#[async_trait]
impl SinkFactory for KafkaSinkFactory {
    fn kind(&self) -> &'static str { "kafka" }

    async fn build(&self, spec: &ResolvedSinkSpec, ctx: &SinkBuildCtx) -> SinkResult<SinkHandle> {
        let sink = KafkaSink::new(&spec.params).await?;
        Ok(SinkHandle::new(Box::new(sink)))
    }
}

Required Methods§

Source

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

Returns the unique type identifier for this sink factory.

Source

fn build<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, spec: &'life1 ResolvedSinkSpec, ctx: &'life2 SinkBuildCtx, ) -> Pin<Box<dyn Future<Output = SinkResult<SinkHandle>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Construct a new sink instance from the given specification.

§Arguments
  • spec - Resolved sink specification with parameters
  • ctx - Build context with runtime configuration
§Returns

A SinkHandle wrapping the constructed sink, or an error.

Provided Methods§

Source

fn validate_spec(&self, _spec: &ResolvedSinkSpec) -> SinkResult<()>

Optional lightweight validation of the sink specification.

Called before build() to catch configuration errors early. Default implementation accepts all specifications.

Implementors§