5 releases

0.1.4 Oct 29, 2024
0.1.3 Oct 19, 2024
0.1.2 Jul 28, 2024
0.1.1 Jan 20, 2024
0.1.0 Jan 14, 2024

#16 in #lua-bindings

Download history 60/week @ 2024-07-29 18/week @ 2024-08-05 22/week @ 2024-08-12 57/week @ 2024-08-19 2/week @ 2024-08-26 65/week @ 2024-09-02 39/week @ 2024-09-09 38/week @ 2024-09-16 13/week @ 2024-09-23 20/week @ 2024-09-30 37/week @ 2024-10-07 151/week @ 2024-10-14 64/week @ 2024-10-21 137/week @ 2024-10-28 10/week @ 2024-11-04 6/week @ 2024-11-11

261 downloads per month

MIT license

29KB
621 lines

mlua-rdkafka

Lua bindings for the Rust based rdkafka.

License Arch Lua

Installing

Add to your Rust project using one of MLua's features: [lua51, lua52, lua53, lua54, luajit, luajit52].

$ cargo add mlua-rdkafka --features luajit

Using

use mlua::Lua;
use mlua_rdkafka;

let lua = Lua::new();
mlua_rdkafka::preload(&lua).unwrap();
let script = r#"
    local rdkafka = require('rdkafka')
    local ClientConfig, OwnedHeaders, FutureRecord = rdkafka.ClientConfig, rdkafka.OwnedHeaders, rdkafka.FutureRecord
    
    -- prepare client
    local client_config = ClientConfig:new()
        :set('group.id', 'mygroup')
        :set('bootstrap.servers', 'mybroker0:9092')
    local future_producer = client_config:create_future_producer()
    
    -- prepare record
    local headers = OwnedHeaders:new():insert('abc', '123')            
    local record = FutureRecord:new():headers(headers)
    
    -- send synchronously
    return future_producer:send(record, 1.0)
"#;
let (partition, offset): (i32, i64) = lua.load(script).eval().unwrap();

Integration Testing

$ KAFKA_BROKERS=127.0.0.1:9092 KAFKA_TOPIC=abc cargo test --features luajit

Dependencies

~16–24MB
~310K SLoC