13 releases

0.2.0 Nov 6, 2021
0.1.3 Mar 6, 2021
0.1.2 Jul 4, 2020
0.1.1 Aug 29, 2019
0.0.1 Nov 26, 2016

#1390 in Data structures

Download history 37/week @ 2025-11-03 46/week @ 2025-11-10 64/week @ 2025-11-17 27/week @ 2025-11-24 18/week @ 2025-12-01 113/week @ 2025-12-08 87/week @ 2025-12-15 95/week @ 2025-12-22 42/week @ 2025-12-29 54/week @ 2026-01-05 133/week @ 2026-01-12 221/week @ 2026-01-19 369/week @ 2026-01-26 586/week @ 2026-02-02 755/week @ 2026-02-09 727/week @ 2026-02-16

2,447 downloads per month
Used in 3 crates

MIT license

105KB
2.5K SLoC

Commit Log

Sequential, disk-backed commit log library for Rust. The library can be used in various higher-level distributed abstractions on top of a distributed log such as Paxos, Chain Replication or Raft.

Crates.io Docs.rs Travis

Documentation

Usage

First, add this to your Cargo.toml:

[dependencies]
commitlog = "0.1"
extern crate commitlog;

use commitlog::*;

fn main() {
    // open a directory called 'log' for segment and index storage
    let opts = LogOptions::new("log");
    let mut log = CommitLog::new(opts).unwrap();

    // append to the log
    log.append("hello world").unwrap(); // offset 0
    log.append("second message").unwrap(); // offset 1

    // read the messages
    let messages = log.read(0, ReadLimit::default()).unwrap();
    for msg in messages.iter() {
        println!("{} - {}", msg.offset(), String::from_utf8_lossy(msg.payload()));
    }

    // prints:
    //    0 - hello world
    //    1 - second message
}

Prior Art

Dependencies

~450–800KB
~11K SLoC