pub trait StreamSourcePort: Send + Sync {
// Required methods
fn subscribe<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
max_events: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StreamEvent>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn source_name(&self) -> &str;
}Expand description
Port trait for streaming data sources.
Implementations connect to event-driven sources and collect events until a termination condition is met (timeout, count limit, or stream close).
§Example
use stygian_graph::ports::stream_source::{StreamSourcePort, StreamEvent};
let events = source
.subscribe("wss://feed.example.com/prices", Some(100))
.await
.unwrap();
for event in &events {
println!("got: {}", event.data);
}Required Methods§
Sourcefn subscribe<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
max_events: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StreamEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn subscribe<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
max_events: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StreamEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Subscribe to a stream and collect events.
§Arguments
url- Stream endpoint (wss://, https:// for SSE, etc.)max_events- Optional cap on number of events to collect before returning.Nonemeans collect until the stream closes or a provider-defined timeout.
§Returns
A vector of collected StreamEvents.
Sourcefn source_name(&self) -> &str
fn source_name(&self) -> &str
Name of this stream source for logging and identification.