Skip to main content

Crate mojay

Crate mojay 

Source
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§

CommittedOffset
The offset committed by a group for a partition of a topic.
Consumer
A member of a consumer group.
ConsumerConfig
Consumer configuration.
ConsumerRecord
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.
PartitionDescription
A partition: its readable offsets and its segments.
PartitionLog
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.
SegmentDescription
A segment file.
TopicConfig
Configuration of a topic, fixed at creation.
TopicDescription
A topic as it is on disk.
TopicReader
A reader of a topic. It takes no lock and modifies nothing: you can open as many as you like while a Producer writes in another process.

Enums§

Error
Errors returned by Mojay.
FsyncPolicy
When to force data to disk.
RebalanceEvent
A change in the partitions owned by a consumer.
StartFrom
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.