pub trait ValidatedSink {
type Validated: Send + Sync + 'static;
// Required methods
fn validate(&self) -> Result<Self::Validated>;
fn build<'life0, 'life1, 'async_trait>(
&'life0 self,
validated: &'life1 Self::Validated,
cx: SinkContext,
) -> Pin<Box<dyn Future<Output = Result<(VectorSink, Healthcheck)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Generic validated-sink trait, implemented by migrated sinks.
The implementor works entirely with their concrete validated type Self::Validated:
#[async_trait]
impl ValidatedSink for MySinkConfig {
type Validated = ValidatedMySink;
fn validate(&self) -> crate::Result<Self::Validated> {
ValidatedMySink::from_config(self)
}
async fn build(
&self,
validated: &Self::Validated,
cx: SinkContext,
) -> crate::Result<(VectorSink, Healthcheck)> {
validated.build(cx).await
}
}The framework automatically erases Self::Validated to Box<dyn Any> and restores
it at build time via DynValidatedSink, so no Any appears in implementor code.
Required Associated Types§
Required Methods§
Sourcefn validate(&self) -> Result<Self::Validated>
fn validate(&self) -> Result<Self::Validated>
Performs pure structural validation, returning the validated state.
This is the same phase as the RFC’s SinkConfig::validate_structure, but it
retains the validated state so build does not redo it.
§Purity Guarantees
This method must be pure: no filesystem access, no network operations, no
credential resolution, no spawning, and no async/await. All such environment-
dependent operations belong in build.
Sourcefn build<'life0, 'life1, 'async_trait>(
&'life0 self,
validated: &'life1 Self::Validated,
cx: SinkContext,
) -> Pin<Box<dyn Future<Output = Result<(VectorSink, Healthcheck)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn build<'life0, 'life1, 'async_trait>(
&'life0 self,
validated: &'life1 Self::Validated,
cx: SinkContext,
) -> Pin<Box<dyn Future<Output = Result<(VectorSink, Healthcheck)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Builds the sink from the validated state, without redoing pure validation.
May perform environment-dependent construction (HTTP clients, schema fetching, etc.).