pub struct PolymarketMarketConnectionPool { /* private fields */ }Expand description
A pool of market-channel WebSocket connections that shards asset subscriptions.
Implementations§
Source§impl PolymarketMarketConnectionPool
impl PolymarketMarketConnectionPool
Sourcepub fn new(
base_url: Option<String>,
subscribe_new_markets: bool,
transport_backend: TransportBackend,
max_subscriptions: usize,
) -> Self
pub fn new( base_url: Option<String>, subscribe_new_markets: bool, transport_backend: TransportBackend, max_subscriptions: usize, ) -> Self
Creates a new market connection pool (unconnected).
A max_subscriptions of 0 is invalid and clamps to
WS_DEFAULT_SUBSCRIPTIONS with a warning.
Sourcepub fn new_with_proxy(
base_url: Option<String>,
subscribe_new_markets: bool,
transport_backend: TransportBackend,
max_subscriptions: usize,
proxy_url: Option<ProxyUrl>,
) -> Self
pub fn new_with_proxy( base_url: Option<String>, subscribe_new_markets: bool, transport_backend: TransportBackend, max_subscriptions: usize, proxy_url: Option<ProxyUrl>, ) -> Self
Creates a new market connection pool with an optional validated proxy URL.
Sourcepub fn handle(&self) -> PolymarketMarketPoolHandle
pub fn handle(&self) -> PolymarketMarketPoolHandle
Returns a cloneable routing handle for use in spawned subscription tasks.
Sourcepub async fn connect(&self) -> Result<()>
pub async fn connect(&self) -> Result<()>
Opens the primary shard and prepares the merged message stream.
§Errors
Returns an error if the primary connection cannot be established.
Sourcepub async fn subscribe_new_markets_feed(&self) -> Result<()>
pub async fn subscribe_new_markets_feed(&self) -> Result<()>
Sends the new-market discovery subscribe on the primary shard.
§Errors
Returns an error if no primary shard is available.
Sourcepub fn take_message_receiver(
&self,
) -> Option<UnboundedReceiver<PolymarketWsMessage>>
pub fn take_message_receiver( &self, ) -> Option<UnboundedReceiver<PolymarketWsMessage>>
Takes the merged message receiver, leaving None in its place.
Sourcepub async fn disconnect(&self) -> Result<()>
pub async fn disconnect(&self) -> Result<()>
Disconnects every shard and clears routing state.
§Errors
Returns an error after attempting every shard when a task or connection does not stop.
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Returns the number of open shard connections.
Sourcepub fn subscription_count(&self) -> usize
pub fn subscription_count(&self) -> usize
Returns the number of unique assets assigned across all shards.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PolymarketMarketConnectionPool
impl !UnwindSafe for PolymarketMarketConnectionPool
impl Freeze for PolymarketMarketConnectionPool
impl Send for PolymarketMarketConnectionPool
impl Sync for PolymarketMarketConnectionPool
impl Unpin for PolymarketMarketConnectionPool
impl UnsafeUnpin for PolymarketMarketConnectionPool
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more