tokio-fluent

Crates.io Documentation CI

A fluentd client using tokio.

Installation

Add this to your Cargo.toml

toml [dependencies] tokio-fluent = "0.3.0"

Example

```rust use std::collections::HashMap;

use tokiofluent::{Client, Config, FluentClient}; use tokiofluent::record::{Map, Value}; use tokiofluent::recordmap;

[tokio::main]

async fn main() { let client = Client::new(&Config { addr: "127.0.0.1:24224".parse().unwrap(), ..Default::default() }) .await .unwrap();

// With Map::new()
let mut map = Map::new();
map.insert("age".to_string(), 22.into());
map.insert(
    "scores".to_string(),
    vec![80, 90]
        .into_iter()
        .map(|e| e.into())
        .collect::<Vec<_>>()
        .into(),
);
client.send("fluent.test", map).unwrap();

// With record_map! macro
let map_from_macro = record_map!(
    "age".to_string() => 22.into(),
    "scores".to_string() => [80, 90].into_iter().map(|e| e.into()).collect::<Vec<_>>().into(),
);
client.send("fluent.test", map_from_macro).unwrap();

} ```

Setting config values

rust let client = Client::new(&Config { addr: "127.0.0.1:24224".parse().unwrap(), ..Default::default() }) .await .unwrap();

timeout

Set the timeout value of std::time::Duration to connect to the destination. The default is 3 seconds.

retry_wait

Set the duration of the initial wait for the first retry, in milliseconds. The actual retry wait will be r * 1.5^(N-1) (r: this value, N: the number of retries). The default is 500.

max_retry

Sets the maximum number of retries. If the number of retries become larger than this value, the write/send operation will fail. The default is 10.

maxretrywait

The maximum duration of wait between retries, in milliseconds. If calculated retry wait is larger than this value, operation will fail. The default is 60,000 (60 seconds).