Coder Social home page Coder Social logo

tokio-fluent's Introduction

tokio-fluent

Crates.io Documentation CI

A fluentd client using tokio.

Installation

Add this to your Cargo.toml

[dependencies]
tokio-fluent = "0.5.0"

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

tokio-fluent's People

Contributors

daandd avatar github-actions[bot] avatar johnmanjiro13 avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tokio-fluent's Issues

Unix domain socket support

Hello,
I have a fork of this repo to support sending logs to fluentd server using unix socket files instead of TCP. The change is simple (commit: main...danielsig727:tokio-fluent:uds_support ), and it's tested on my own project.

I'd like to back-port to here. However, I need your opinion on the interface change.
In my fork, for simplicity, I changed fn new(config: &Config) to new_tcp(addr: SocketAddr, config: &Config) and new_unix(path: &str, config: &Config), and removed addr from Config. Another way could be keeping fn new(config: &Config) and Config.addr for backward compatibility, and adding new_unix(path: &str, config: &Config) but it neglects the addr. What do you think? Thank you

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

cargo
Cargo.toml
  • base64 0.21.5
  • bytes 1.4.0
  • chrono 0.4.26
  • log 0.4.20
  • rmp-serde 1.1.2
  • serde 1.0.183
  • tokio 1.31.0
  • uuid 1.5.0
  • tokio 1.31.0
github-actions
.github/workflows/tagpr.yml
  • actions/checkout v4
  • Songmu/tagpr v1
  • actions/checkout v4
  • actions-rs/toolchain v1
.github/workflows/test.yml
  • actions/checkout v4
  • actions-rs/toolchain v1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.