tokio-fluent

Crates.iotokio-fluent
lib.rstokio-fluent
version
sourcesrc
created_at2023-01-07 14:28:25.726504
updated_at2024-12-02 11:28:08.508457
descriptionA fluentd client using tokio
homepage
repositoryhttps://github.com/johnmanjiro13/tokio-fluent
max_upload_size
id753072
Cargo.toml error:TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Ikumi Nakamura (johnmanjiro13)

documentation

README

tokio-fluent

Crates.io Documentation CI

A fluentd client using tokio.

Installation

Add this to your Cargo.toml

[dependencies]
tokio-fluent = "0.5.1"

Example

use std::collections::HashMap;

use tokio_fluent::{Client, Config, FluentClient};
use tokio_fluent::record::{Map, Value};
use tokio_fluent::record_map;

#[tokio::main]
async fn main() {
    // Connect to server using TCP
    let client = Client::new_tcp(
        "127.0.0.1:24224".parse().unwrap(),
        &Config {..Default::default()}
    )
    .await
    .unwrap();
    // Or connecting using unix socket
    let client_unix = Client::new_unix(
        "/path/to/fluentd.sock",
        &Config {..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

let client = Client::new_tcp(
        "127.0.0.1:24224".parse().unwrap(),
        &Config {..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.

max_retry_wait

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

max_connection_lifetime

The maximum lifetime of a connection before reconnection is attempted.

Note that reconnection is only triggered when new log lines are sent. If no new log lines are received within this timeframe, the connection will remain open, even if it's older than the value. The default is 0 (no reconnection).

Commit count: 143

cargo fmt