crab-kafka

Crates.iocrab-kafka
lib.rscrab-kafka
version0.0.7
sourcesrc
created_at2023-05-27 15:42:00.503126
updated_at2024-11-14 10:17:17.572628
descriptionForward + TLS traffic to kafka
homepagehttps://github.com/newfla/crab-kafka
repositoryhttps://github.com/newfla/crab-kafka
max_upload_size
id875984
size113,178
Flavio Bizzarri (newfla)

documentation

README

crab_kafka

Crates.io Apache licensed Docs.rs

Forward <TCP|UDP> + TLS traffic to kafka.

Based on tokio and rust rdkafka

Basic Usage

It's strongly encouraged the use of alternative allocator like MiMalloc

use anyhow::Result;
use std::collections::HashMap;
use mimalloc::MiMalloc;
use crab_kafka::{forwarder::ForwarderBuilder,Receiver,PartitionStrategies,CheckpointStrategies,TransformStrategies};

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

#[tokio::main]
async fn main() -> Result<()> {
    ForwarderBuilder::default()
    .receiver(Receiver::new_tcp_stream("127.0.0.1".to_owned(), "8888".to_owned(), 2000))
    .checkpoint(CheckpointStrategies::OpenDoors)
    .partition(PartitionStrategies::new_sticky_round_robin())
    .transform(TransformStrategies::NoTransform)
    .kafka_settings(HashMap::from([("bootstrap.servers".to_owned(),"broker:29091".to_owned())]))
    .topic("test_topic".to_owned())
    .cache_size(1000)
    .stats_interval(10)
    .build()
    .unwrap()
    .await
}

Examples

Commit count: 65

cargo fmt