[][src]Struct nsq_client::Config

pub struct Config {
    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,
}

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

Methods

impl Config[src]

pub fn new() -> Config[src]

Create default Config

use nsq_client::{Config};

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

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

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()));
}

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

Change hostname

use nsq_client::Config;

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

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

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

impl Default for Config[src]

impl Clone for Config[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<Config> for Config[src]

impl Debug for Config[src]

impl Serialize for Config[src]

impl<'de> Deserialize<'de> for Config[src]

Auto Trait Implementations

impl Send for Config

impl Sync for Config

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Erased for T

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