Skip to main content

ConnectionConfig

Struct ConnectionConfig 

Source
pub struct ConnectionConfig {
    pub endpoint: Endpoint,
    pub reconnect: ReconnectConfig,
    pub connect_timeout: Duration,
    pub depth: Depth,
    pub heartbeat_timeout: Option<Duration>,
    pub channel_capacity: Option<usize>,
    pub backpressure_policy: BackpressurePolicy,
    pub circuit_breaker: Option<CircuitBreakerConfig>,
}
Expand description

Configuration for the WebSocket connection

Fields§

§endpoint: Endpoint

WebSocket endpoint

§reconnect: ReconnectConfig

Reconnection settings

§connect_timeout: Duration

Connection timeout

§depth: Depth

Orderbook depth to subscribe with

§heartbeat_timeout: Option<Duration>

Heartbeat timeout - disconnect if no heartbeat received within this duration Kraken sends heartbeats every ~5 seconds; default timeout is 30 seconds

§channel_capacity: Option<usize>

Event channel capacity (None = unbounded)

§backpressure_policy: BackpressurePolicy

Backpressure policy when channel is full

§circuit_breaker: Option<CircuitBreakerConfig>

Circuit breaker configuration (None = disabled)

Implementations§

Source§

impl ConnectionConfig

Source

pub fn new() -> Self

Create a new config with default values

Source

pub fn with_endpoint(self, endpoint: Endpoint) -> Self

Set the endpoint

Source

pub fn with_reconnect(self, config: ReconnectConfig) -> Self

Set reconnection config

Source

pub fn without_reconnect(self) -> Self

Disable automatic reconnection

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Set connection timeout

Source

pub fn with_depth(self, depth: Depth) -> Self

Set orderbook depth

Source

pub fn with_heartbeat_timeout(self, timeout: Duration) -> Self

Set heartbeat timeout

If no message is received within this duration, the connection is considered dead and will be reconnected.

Source

pub fn without_heartbeat_timeout(self) -> Self

Disable heartbeat timeout monitoring

Source

pub fn with_channel_capacity( self, capacity: usize, policy: BackpressurePolicy, ) -> Self

Set bounded channel capacity for backpressure handling

When the channel is full and a new event arrives:

  • DropNewest: The new event is dropped (default)
  • Block: The sender blocks until space is available (may cause connection issues)

Recommended capacity: 1000-10000 depending on message rate

Source

pub fn with_unbounded_channel(self) -> Self

Use unbounded channel (no backpressure, unlimited memory growth)

Source

pub fn with_circuit_breaker(self, config: CircuitBreakerConfig) -> Self

Enable circuit breaker with custom configuration

The circuit breaker prevents repeated connection attempts when the service appears unhealthy, giving it time to recover.

Source

pub fn without_circuit_breaker(self) -> Self

Disable circuit breaker

Trait Implementations§

Source§

impl Clone for ConnectionConfig

Source§

fn clone(&self) -> ConnectionConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConnectionConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConnectionConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more