Crates.io | mlua-rdkafka |
lib.rs | mlua-rdkafka |
version | 0.1.4 |
source | src |
created_at | 2024-01-14 17:38:14.725391 |
updated_at | 2024-10-29 13:24:57.676442 |
description | Lua bindings for rdkafka. |
homepage | https://on-prem.net |
repository | https://gitlab.com/megalithic-llc/mlua-rdkafka.git |
max_upload_size | |
id | 1099592 |
size | 33,470 |
Lua bindings for the Rust based rdkafka.
Add to your Rust project using one of MLua's features: [lua51, lua52, lua53, lua54, luajit, luajit52].
$ cargo add mlua-rdkafka --features luajit
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();
$ KAFKA_BROKERS=127.0.0.1:9092 KAFKA_TOPIC=abc cargo test --features luajit