No server
A Mojay database is a folder, like a SQLite file. Nothing to deploy, run or monitor: your application links the library and reads and writes the files directly.
Many processes
Any number of producers and consumers, in any process on the machine, on the same topic and even the same partition. They coordinate through file locks.
Consumer groups
Members of a group share the partitions and commit offsets, like Kafka. When a member joins, leaves or crashes, the others rebalance, without any coordinator.
Durable by default
A message is on disk before anyone can read it, and concurrent writers share flushes. After a crash, recovery keeps every complete record and only drops a half-written tail.
A library, not a service
Open a folder, create topics, produce and consume. Errors are typed, and damaged data on disk comes back as an error, never as a crash.
Start with Rustuse std::time::Duration;
use mojay::{ConsumerConfig, Db, Message, TopicConfig};
fn main() -> mojay::Result<()> {
let db = Db::open("data")?;
let config = TopicConfig { partitions: 3, ..Default::default() };
db.create_topic("orders", config)?;
// Same key, same partition: a customer's orders stay in order.
let mut producer = db.producer("orders")?;
producer.send(&Message::new("customer-42", r#"{"total": 99}"#))?;
// A member of the "billing" group gets its share of the partitions.
let config = ConsumerConfig::default();
let mut consumer = db.consumer("billing", &["orders"], config)?;
for record in consumer.poll(Duration::from_millis(500))? {
println!("{}:{}", record.partition, record.offset);
}
consumer.commit()
}
Async, and never blocking the event loop
The Node.js package wraps the same library. Each producer and consumer runs on its own thread, and every call returns a Promise.
Start with Node.jsimport { Db } from "mojay";
const db = Db.open("data");
db.createTopic("orders", { partitions: 3 });
const producer = db.producer("orders");
const { partition, offset } = await producer.send({
key: "customer-42",
value: JSON.stringify({ total: 99 }),
});
// Another process can run the same code: they share the partitions.
const consumer = db.consumer("billing", ["orders"], { autoCommitMs: 1000 });
for (const record of await consumer.poll(500)) {
console.log(record.partition, record.offset, record.value?.toString());
}
await consumer.close();
See what your app is doing
The mojay command creates topics, sends and tails messages, describes partitions and consumer lag, and dumps segments byte by byte.
# Create a topic, send a message, follow the stream.
mojay create-topic orders --partitions 3
echo '{"total": 99}' | mojay produce orders --key customer-42
mojay tail orders --follow
# See what is really on disk.
mojay describe orders
mojay dump orders -p 0 --index
Fast enough to forget about it
written in batches of 100, fsync left to the OS
written in batches of 100, each batch on disk first
read from a partition
of memory for the whole benchmark run
100-byte messages on an Apple M5 laptop. Method and full results.
Mojay was created to prototype Kafka-style designs locally, without the burden of running Kafka.
Made for
- Prototyping event-driven designs on your laptop, with no broker to install
- Tests: a real log in a temporary folder, created and thrown away in milliseconds
- CI pipelines, where starting a Kafka cluster is slow and flaky
- Demos and local development environments
Not the right tool
- Several machines sharing one stream: there is no network or replication
- Clients that speak the Kafka protocol: Mojay is a library, not a broker
- Network file systems: locks and fsync need a local disk
In production, at your own risk for now
Mojay can also run in real applications on one machine: passing events and jobs between processes, a durable queue for a desktop, CLI or edge application, a local event log to replay. It is built with care for durability and crash recovery, but it is young and has not yet been proven in production. If you use it there, test it against your own failure scenarios and keep a way back.
Stream in a folder.
Five minutes from install to your first consumer group.