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
impl Config
Sourcepub fn new() -> Config
pub fn new() -> Config
Create default Config
use nsq_client::{Config};
fn main() {
let config = Config::new();
assert_eq!(config, Config::default());
}
Sourcepub fn client_id<S: Into<String>>(self, client_id: S) -> Self
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()));
}
Sourcepub fn hostname<S: Into<String>>(self, hostname: S) -> Self
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()));
}
Sourcepub fn user_agent<S: Into<String>>(self, user_agent: S) -> Self
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()));
}