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

#606 in Data structures

Download history 31/week @ 2023-12-18 27/week @ 2023-12-25 9/week @ 2024-01-08 5/week @ 2024-01-15 4/week @ 2024-01-22 1/week @ 2024-02-05 19/week @ 2024-02-12 48/week @ 2024-02-19 102/week @ 2024-02-26 42/week @ 2024-03-04 44/week @ 2024-03-11 38/week @ 2024-03-18 45/week @ 2024-03-25 179/week @ 2024-04-01

313 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

~420–750KB
~10K SLoC