Expand description
Mojay: topics, partitions, offsets and consumer groups in a local directory, with no server. The SQLite of Kafka.
use std::time::Duration;
use mojay::{ConsumerConfig, Db, Message, TopicConfig};
let db = Db::open("./data")?;
db.create_topic("orders", TopicConfig { partitions: 4, ..Default::default() })?;
let mut producer = db.producer("orders")?;
producer.send(&Message::new("client-42", "order"))?;
let mut consumer = db.consumer("billing", &["orders"], ConsumerConfig::default())?;
for record in consumer.poll(Duration::from_millis(500))? {
println!("{} / {} : {:?}", record.partition, record.offset, record.value);
}
consumer.commit()?;Modules§
- inspect
- Segment inspection, for debugging: shows what is actually stored, byte by byte. Read-only: nothing is ever repaired.
Structs§
- Committed
Offset - The offset committed by a group for a partition of a topic.
- Consumer
- A member of a consumer group.
- Consumer
Config - Consumer configuration.
- Consumer
Record - A message read by a consumer, with its origin.
- Db
- A Mojay data directory, the equivalent of an SQLite database file.
- Header
- A message header: a text key and a binary value, as in Kafka.
- LogConfig
- Configuration of a partition log.
- Message
- A message to produce. The offset is assigned by the log.
- Partition
Description - A partition: its readable offsets and its segments.
- Partition
Log - The append-only log of a partition, stored in its own directory.
- Producer
- A topic’s writer.
- Record
- A record read from the log.
- Retention
- Retention limits of a partition. None by default: everything is kept.
- Segment
Description - A segment file.
- Topic
Config - Configuration of a topic, fixed at creation.
- Topic
Description - A topic as it is on disk.
- Topic
Reader - A reader of a topic. It takes no lock and modifies nothing:
you can open as many as you like while a
Producerwrites in another process.
Enums§
- Error
- Errors returned by Mojay.
- Fsync
Policy - When to force data to disk.
- Rebalance
Event - A change in the partitions owned by a consumer.
- Start
From - Where to start reading a partition that has no usable committed offset.
Constants§
- MAX_
RECORD_ SIZE - Maximum size of an encoded record, including the length prefix.
Type Aliases§
- Result
- The result type of Mojay operations.