pub async fn init_market_stream<Exchange, Instrument, Kind>(
policy: ReconnectionBackoffPolicy,
subscriber: Exchange::Subscriber,
subscriptions: Vec<Subscription<Exchange, Instrument, Kind>>,
) -> Result<impl Stream<Item = MarketStreamResult<Instrument::Key, Kind::Event>>, DataError>where
Exchange: StreamSelector<Instrument, Kind>,
Instrument: InstrumentData + Display,
Kind: SubscriptionKind + Display,
Subscription<Exchange, Instrument, Kind>: Identifier<Exchange::Channel> + Identifier<Exchange::Market>,Expand description
Initialises a reconnecting MarketStream using a collection of
Subscriptions.
The provided ReconnectionBackoffPolicy dictates how the exponential backoff scales
between reconnections.
The subscriber is cloned into the reconnect closure, so authenticated subscribers
will have their credentials available on reconnection.
§Errors
Returns the first initialisation’s error. A batch the venue did not fully acknowledge is
DataError::SubscriptionsUnacknowledged, naming the subscriptions that received no
acknowledgement.
§Re-initialisation
When the stream ends it yields one reconnect::Event::Reconnecting and re-initialises with
exponential backoff. Each failed attempt yields an Event::Item(Err(DataError::ReinitFailed))
counting consecutive failures; retrying continues until an attempt succeeds. Deciding when to
give up, or to drop a subscription the venue no longer accepts, is the caller’s.