pub struct DataLoader<S: DataSource = TradingViewSource> { /* private fields */ }Expand description
Event-driven data loader — connects a source to multiple sinks.
Architecture:
Source task → source_tx ──→ [fan-out task] ──→ sink_tx_0 → sink task 0
├───────→ sink_tx_1 → sink task 1
└───────→ sink_tx_N → sink task NThe source produces Vec<MarketEvent> batches and sends them via a single
mpsc channel. A fan-out task reads from that channel and clones each
batch to every sink’s individual channel. Each sink has its own task that
reads from its channel and calls sink.accept().
Implementations§
Source§impl<S: DataSource> DataLoader<S>
impl<S: DataSource> DataLoader<S>
Sourcepub fn builder() -> DataLoaderBuilder<S>
pub fn builder() -> DataLoaderBuilder<S>
Create a new builder with default configuration.
Sourcepub async fn start(&mut self) -> Result<()>
pub async fn start(&mut self) -> Result<()>
Start the loader: spawns source, fan-out, and per-sink tasks.
This method consumes the source and sink channels; calling it twice returns an error.
Sourcepub async fn shutdown(&mut self) -> Result<()>
pub async fn shutdown(&mut self) -> Result<()>
Initiate graceful shutdown.
Cancels all spawned tasks and waits for them to finish.
Sourcepub fn cancel_token(&self) -> CancellationToken
pub fn cancel_token(&self) -> CancellationToken
Returns a clone of the cancellation token for external monitoring.
Auto Trait Implementations§
impl<S = TradingViewSource> !RefUnwindSafe for DataLoader<S>
impl<S = TradingViewSource> !UnwindSafe for DataLoader<S>
impl<S> Freeze for DataLoader<S>where
S: Freeze,
impl<S> Send for DataLoader<S>
impl<S> Sync for DataLoader<S>
impl<S> Unpin for DataLoader<S>where
S: Unpin,
impl<S> UnsafeUnpin for DataLoader<S>where
S: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more