Struct Config

Source
pub struct Config {
Show 13 fields pub client_id: Option<String>, pub hostname: Option<String>, pub feature_negotiation: bool, pub heartbeat_interval: i64, pub output_buffer_size: u64, pub output_buffer_timeout: u32, pub tls_v1: bool, pub snappy: bool, pub deflate: bool, pub deflate_level: u16, pub sample_rate: u16, pub user_agent: String, pub message_timeout: u32,
}
Expand description

Configuration sent to nsqd to properly config the Connection

§Examples

 use nsq_client::{Connection, Config};

 fn main() {
     let sys = System::new("consumer");
     let config = Config::new().client_id("consumer").user_agent("node-1");
     Supervisor::start(|_| Connection::new(
         "test",
         "test",
         "0.0.0.0:4150",
         Some(config),
         None,
         None,
     ));
     sys.run();
 }

Fields§

§client_id: Option<String>

Identifiers sent to nsqd representing this client (consumer specific)

Default: hostname where connection is started

§hostname: Option<String>

Hostname where client is deployed.

Default: hostname where connection is started

§feature_negotiation: bool

Enable feature_negotiation

Default: true

§heartbeat_interval: i64

Duration of time between heartbeats (milliseconds).

Valid values:

  • -1 disables heartbeats
  • 1000 <= heartbeat_interval <= configured_max

Default: 30000

§output_buffer_size: u64

Size of the buffer (in bytes) used by nsqd for buffering writes to this connection

Valid values:

  • -1 disable output buffer
  • 64 <= output_buffer_size <= configured_max

Default: 16384

§output_buffer_timeout: u32

The timeout after which data nsqd has buffered will be flushed to this client.

Valid values:

  • -1 disable buffer timeout
  • 1ms <= output_buffer_timeout <= configured_max

Default: 250

§tls_v1: bool

Enable TLS negotiation

Default: false (Not implemented)

§snappy: bool

Enable snappy compression.

Default: false (Not implemented)

§deflate: bool

Enable deflate compression.

Default: false (Not implemented)

§deflate_level: u16

Configure deflate compression level.

Valid range:

  • 1 <= deflate_level <= configured_max

Default: 6

§sample_rate: u16

Integer percentage to sample the channel.

Deliver a perventage of all messages received to this connection.

Default: 0

§user_agent: String

String indentifying the agent for this connection.

Default: hostname where connection is started

§message_timeout: u32

Timeout used by nsqd before flushing buffered writes (set to 0 to disable).

Default: 0

Implementations§

Source§

impl Config

Source

pub fn new() -> Config

Create default Config

use nsq_client::{Config};

fn main() {
    let config = Config::new();
    assert_eq!(config, Config::default());
}
Source

pub fn client_id<S: Into<String>>(self, client_id: S) -> Self

Change client_id

use nsq_client::Config;

fn main() {
    let config = Config::new().client_id("consumer");
    assert_eq!(config.client_id, Some("consumer".to_owned()));
}
Source

pub fn hostname<S: Into<String>>(self, hostname: S) -> Self

Change hostname

use nsq_client::Config;

fn main() {
    let config = Config::new().hostname("node-1");
    assert_eq!(config.hostname, Some("node-1".to_owned()));
}
Source

pub fn user_agent<S: Into<String>>(self, user_agent: S) -> Self

Change user_agent

use nsq_client::Config;

fn main() {
    let config = Config::new().user_agent("consumer-1");
    assert_eq!(config.user_agent, Some("consumer-1".to_owned()));
}

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
Source§

impl Default for Config

Source§

fn default() -> Config

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

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Config

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Erased for T