Skip to main content

PollSource

Trait PollSource 

Source
pub trait PollSource<T: DataPoint>:
    Send
    + Sync
    + 'static {
    // Required methods
    fn poll(
        &self,
        hub: Arc<ExchangeHub>,
        exchange: ExchangeId,
        account_type: AccountType,
        symbol: String,
    ) -> impl Future<Output = Result<Vec<T>>> + Send;
    fn cadence(&self) -> Duration;
}
Expand description

REST poll contract for one (kind, exchange, symbol) combination.

poll is called on every interval tick and returns all records the exchange has available (not just the newest one), allowing the caller to dedup by timestamp_ms and emit only genuinely new points.

The trait uses stable AFIT (available since Rust 1.75). No async_trait macro is needed.

§Wasm note

The native spawn_poller requires the returned future to be Send (for tokio::spawn). Concrete implementations must therefore return Send futures on native. On wasm spawn_poller is not compiled, so no Send requirement is imposed — the REST future may be !Send.

Required Methods§

Source

fn poll( &self, hub: Arc<ExchangeHub>, exchange: ExchangeId, account_type: AccountType, symbol: String, ) -> impl Future<Output = Result<Vec<T>>> + Send

Fetch recent data points from the exchange.

Implementations should request the last ~500 buckets with no start_time filter. This gives the poller a built-in warm-start on the first tick without a separate backfill path.

Return Err(String) on any REST failure. The caller logs + retries on the next tick without exiting the actor.

Source

fn cadence(&self) -> Duration

Polling cadence — taken from PollSpec at construction time.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§