pub trait DataSinkPort: Send + Sync {
// Required methods
fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SinkRecord,
) -> Pin<Box<dyn Future<Output = Result<SinkReceipt, DataSinkError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SinkRecord,
) -> Pin<Box<dyn Future<Output = Result<(), DataSinkError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DataSinkError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Outbound data sink port — publish scraped records to an external system.
Implementations live in adapters/ and are never imported by domain code.
The port is always injected via Arc<dyn DataSinkPort>.
§Object safety
Native async fn in traits is not object-safe by itself. This trait uses
#[async_trait], which erases async methods into boxed futures and enables
usage as dyn DataSinkPort through Arc in this workspace.
§Example
use stygian_graph::ports::data_sink::{DataSinkPort, SinkRecord, SinkReceipt, DataSinkError};
struct NoopSink;
#[async_trait::async_trait]
impl DataSinkPort for NoopSink {
async fn publish(&self, _record: &SinkRecord) -> Result<SinkReceipt, DataSinkError> {
Ok(SinkReceipt {
id: "noop".to_string(),
published_at: "".to_string(),
platform: "noop".to_string(),
})
}
async fn validate(&self, _record: &SinkRecord) -> Result<(), DataSinkError> {
Ok(())
}
async fn health_check(&self) -> Result<(), DataSinkError> {
Ok(())
}
}Required Methods§
Sourcefn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SinkRecord,
) -> Pin<Box<dyn Future<Output = Result<SinkReceipt, DataSinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SinkRecord,
) -> Pin<Box<dyn Future<Output = Result<SinkReceipt, DataSinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Validate and publish record to the sink.
Implementations should validate the record before publishing; failing
fast with DataSinkError::ValidationFailed is preferred over sending
invalid data downstream.
§Errors
Returns DataSinkError on validation failure, transport error, or
rate-limit/auth rejection.
Sourcefn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SinkRecord,
) -> Pin<Box<dyn Future<Output = Result<(), DataSinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SinkRecord,
) -> Pin<Box<dyn Future<Output = Result<(), DataSinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Validate record without publishing it.
Useful for preflight checks without side effects.
§Errors
Returns DataSinkError::ValidationFailed if the record is malformed
or violates schema constraints.
Sourcefn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DataSinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), DataSinkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check that the sink backend is reachable and healthy.
§Errors
Returns DataSinkError::PublishFailed or DataSinkError::Unauthorized
if the backend is unreachable or misconfigured.