#tcp-udp #kafka #tls #udp #tcp

crab-kafka

Forward <TCP|UDP> + TLS traffic to kafka

7 releases

0.0.7 Nov 14, 2024
0.0.6 Sep 13, 2024
0.0.5 Jul 6, 2024
0.0.4 Sep 16, 2023
0.0.2 May 28, 2023

#1705 in Network programming

Download history 97/week @ 2024-09-07 55/week @ 2024-09-14 8/week @ 2024-09-21 17/week @ 2024-09-28 2/week @ 2024-10-05 8/week @ 2024-10-12 2/week @ 2024-10-19 9/week @ 2024-11-02 105/week @ 2024-11-09 22/week @ 2024-11-16 3/week @ 2024-11-23

139 downloads per month

Apache-2.0

52KB
1K SLoC

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

Dependencies

~26–41MB
~644K SLoC