Struct Config

Source
pub struct Config { /* private fields */ }
Expand description

Configuration of carbon protocol

This configuration is used both for single connection and connection pool.

Implementations§

Source§

impl Config

Source

pub fn new() -> Config

Create the config builder with all defaults

Source

pub fn reconnect_delay(&mut self, delay: Duration) -> &mut Self

Set the reconnect delay

Actual delay is chosen each time as a random millisecond from 0.5 of this value to 1.5 for this value.

Note: reconnect delay is calculated since previous connection attempt. I.e. if connection is broken after a minute of normal work it will reconnect immediately.

Source

pub fn reconnect_delay_min_max( &mut self, min_delay: Duration, max_delay: Duration, ) -> &mut Self

Set the reconnect delay bounds to more specific values

Actual delay is chosen each time as a random millisecond from the range of min_delay..max_delay. Usually it’s enough to set reconnect_delay but you can use this method if you need more tight control.

Note: reconnect delay is calculated since previous connection attempt. I.e. if connection is broken after a minute of normal work it will reconnect immediately.

Source

pub fn write_timeout(&mut self, dur: Duration) -> &mut Self

Timeout of writing at least some byte when there are any bytes in the outgoing buffer

Source

pub fn watermarks(&mut self, low: usize, high: usize) -> &mut Self

Buffer limits or watermarks

The rules of thumb to not to loose any metrics:

  • Low watermark is efficient buffer size for sending to network
  • High watermark is maximum buffer size, should be much larger to compensate when individual host becomes slower
§Details

When number of bytes buffered reaches low watermark (in all connections) we stop pulling metrics from the internal channel. The latter will start to drop messages after max_metrics_buffered is reached.

When number of bytes buffered reaches high watermark in any specific connection we drop connection entirely, as this means connection can’t keep up with the traffic (but write_timeout has not reached for some reason, for example it accepts bytes in small chunks).

High water mark should be at least one metric larger than low watermark or connection will be dropped whenever watermark is reached. For single connection high watermark should still be higher, but otherwise there is no chance it will be reached beyond single metric.

§Panics

Panics if high watermark is smaller than low watermark or watermark is zero.

Source

pub fn max_metrics_buffered(&mut self, metrics: usize) -> &mut Self

Maximum metrics buffered in a channel

The rule of thumb: this channel should contain as much metrics as might be sent within the period of the downtime + reconnect time for the carbon backend (in order to not to loose any values). Probably 10 seconds or 30 seconds worth of metrics at least.

This buffer is common for all the underlying channel between Carbon instance and the actual Proto or Pool. This channel is single one for all underlying connections.

Source

pub fn done(&mut self) -> Arc<Config>

Create a Arc’d config clone to pass to the constructor

This is just a convenience method.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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, 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> 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.