3 releases

0.1.2 May 11, 2024
0.1.1 Mar 9, 2024
0.1.0 Mar 2, 2024

#8 in #lua-bindings

MIT license

23KB
419 lines

mlua-samsa

Lua bindings for the Samsa kafka client.

License Arch Lua

Installing

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

$ cargo add mlua-samsa --features luajit

Using

use mlua::Lua;
use mlua_samsa;

let lua = Lua::new();
mlua_samsa::preload(&lua)?;
let script = r#"
    local samsa = require('samsa')
    local bootstrap_addrs = 'localhost:9092'
    local topic = 'my-topic'
    local producer = samsa.ProducerBuilder:new(bootstrap_addrs, topic):build()
    
    local message = {
        partition_id = 0,
        topic = topic,
        key = 'my-key',
        value = 'my-value',
    }
    producer:produce(message)     
"#;
lua.load(script).exec()?;

Testing

$ make check

Integration Testing

$ KAFKA_BROKERS=127.0.0.1:9092 KAFKA_TOPIC=abc make check

Dependencies

~19–29MB
~544K SLoC