Skip to main content

binlog

Test crates.io API docs

A rust library for creating and managing logs of arbitrary binary data. Presently it's used to collect sensor data. But it should generally be helpful in cases where you need to store timeseries data, in a nearly (but not strictly) append-only fashion.

The underlying storage of logs are pluggable via a few traits. Binlog includes built-in implementations via sqlite, redis, and in-memory-only. Additionally, python bindings allow you to use (a subset of) binlog from python.

Usage

From Rust

A small example:

use binlog::{Entry, Error, Range, RangeableStore, SqliteStore, Store};
use std::borrow::Cow;
use string_cache::Atom;

/// Demonstrates the sqlite store, with results in `example.db`. You may want to delete that before
/// running this to see the results of this on an empty database.
fn main() -> Result<(), Error> {
    // Create a new datastore with sqlite backing. The result will be stored in example.db, with
    // default compression options. In-memory is also possible via
    // `binlog::MemoryStore::default()`.
    let store = SqliteStore::new("example.db", None)?;

    // Add 10 entries.
    for i in 1..11u8 {
        let entry = Entry::new_with_timestamp(i as i64, Atom::from("sqlite_example"), vec![i]);
        store.push(Cow::Owned(entry))?;
    }

    // Queries are done via `range`. Here we grab entries with any timestamp and any name.
    let range = store.range(.., Option::<String>::None)?;
    // Count the number of entries.
    println!("initial count: {}", range.count()?);
    // We can also iterate on the entries.
    for entry in range.iter()? {
        println!("entry: {:?}", entry?);
    }

    // Remove the entries with 4 <= ts <= 6 and with the name `sqlite_example`.
    store.range(4..=6, Some(Atom::from("sqlite_example")))?.remove()?;

    // Now get the range of entries with 5 <= ts and with the name `sqlite_example`.
    let range = store.range(5.., Some(Atom::from("sqlite_example")))?;
    println!("count after range deletion: {}", range.count()?);
    for entry in range.iter()? {
        println!("entry: {:?}", entry?);
    }

    Ok(())
}

From Python

A small example:

from binlog import binlog
store = binlog.SqliteStore("example.db")
store.push(binlog.Entry(1, "pytest_push", [1, 2, 3]))

Stores

Stores implement the Store trait, and zero or more optional extensions depending on their supported functionality. A few stores implementations are built-in to binlog:

In-memory-only

The in-memory-only store has no means of persistence, but offers the full log functionality. This is also used internally for fuzzing other implementations against.

Redis

The redis implementation is enableable via the redis-store feature. Under the hood, it uses redis streams. It supports subscriptions, but not ranges.

Sqlite

The sqlite implementation is enableable via the sqlite-store feature. It supports ranges, but not subscriptions.

Testing

Unit tests

Tests can be run via make test. This will also be run in CI.

Benchmarks

Benchmarks can be run via make bench.

Fuzzing

A fuzzer is available, ensuring the the sqlite and in-memory datastores operate identically. Run it via make fuzz.

Checks

Lint and formatting checks can be run via make check. Equivalent checks will also run in CI.

Metadata

Release files for binlog 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for binlog 0.5.0
File Size Uploaded
binlog-0.5.0.tar.gz 34.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for binlog 0.5.0
File
binlog-0.5.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl PyPy 3.7 PyPy 3.7 7.3 Linux glibc 2.5+ x86-64 Details
binlog-0.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.5+ x86-64 Details
binlog-0.5.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64, macOS 10.9+ x86-64, macOS 10.9+ universal2 (ARM64, x86-64) Details
binlog-0.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.5+ x86-64 Details
binlog-0.5.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64, macOS 10.9+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64 Details
binlog-0.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
binlog-0.5.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl CPython 3.8 CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64, macOS 10.9+ x86-64 Details
binlog-0.5.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
binlog-0.5.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl CPython 3.7 CPython 3.7 pymalloc macOS 11.0+ ARM64, macOS 10.9+ x86-64, macOS 10.9+ universal2 (ARM64, x86-64) Details

Total release size: 20.9 MB

Release files / binlog-0.5.0.tar.gz

Download URL binlog-0.5.0.tar.gz
Size 34.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9db3bff7d4cae803625c31e4922077eec8bde97750b512745de92831fcf57fc9
BLAKE2b-256 checksum
How to use checksums
5ee9cec725214d5b6c029a9834675c67784db5cd4ebb4c1a84492e2a63931f5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL binlog-0.5.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 2.5 MB
Tags Linux glibc 2.5+ x86-64 PyPy 3.7 PyPy 3.7 7.3
SHA-256 checksum
How to use checksums
2bc464c76734673ed44ee50e9848f82cabe452dc6a1b5eedbf9507950fe05e4f
BLAKE2b-256 checksum
How to use checksums
09a7ff9276c46fa18a2dceeb07577d01b9a1010c855017ce3a82913bb2f30d0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL binlog-0.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 2.5 MB
Tags CPython 3.10 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
17a5133b668d99cbbbffe943fa07a72d585d5ae52d76f1aa001c740dd8acbc2a
BLAKE2b-256 checksum
How to use checksums
4dbe9090a4a745c7a988b9825a80fd2ecdcaace17b9360aaf55f54fec168fc00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Download URL binlog-0.5.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 2.0 MB
Tags CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
eaac765457a2a5a514234ee46d6b5e404c4e97bf24cfea4d1bb4770adadad6b4
BLAKE2b-256 checksum
How to use checksums
2238e63bff731756044236c83b252787b17ca3a76303122ba3e6ad648e4fe525
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL binlog-0.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 2.5 MB
Tags CPython 3.9 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
124ae3802657c9d1ed0f99d8ee654d2fcbc9e8e286e708ee2838cb8e392e336a
BLAKE2b-256 checksum
How to use checksums
c4d2143adac2a1550603e910e65a9bd8180bc7c78b03a3699511b63b68ac3286
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Download URL binlog-0.5.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 2.0 MB
Tags CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5b22f0c60574a30f6fd7ca5a4beb7f5b0a407801df84591600704b6b50f691d9
BLAKE2b-256 checksum
How to use checksums
0f46074135c144210e94f02df3caefd9b13a73cbf6332ffb7f4382eb3ca18856
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL binlog-0.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 2.5 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
de8d875404b7cddb319bb7ed55d81f716242d9fc05c5741696b5118531f34e87
BLAKE2b-256 checksum
How to use checksums
660db8f712476773944d3d819cfe4a23352e38f8c708b48578fcda72ff0afc06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Download URL binlog-0.5.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 2.0 MB
Tags CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c703b49873051ab5885658c8ddb41d21a214847478cd3e96d03c77971a5a4f38
BLAKE2b-256 checksum
How to use checksums
4f7b5746d843903bca4aa50445db86eefe09ef40d6eae7ae646e433015eeb935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL binlog-0.5.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 2.5 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
72802d51eef32735a9e60e99209c6672f07345f9d20d7ecabf15c30ac96c21c2
BLAKE2b-256 checksum
How to use checksums
846b8161b30fbaf62846e1b812dd781bbbcf05c53c56c62ed92d52abc81e9907
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release files / binlog-0.5.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Download URL binlog-0.5.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 2.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0e2fbb7150010836f83fc979228fb9c7c723028c0387466ff7eb35b9426b5f6d
BLAKE2b-256 checksum
How to use checksums
bb9186f818e69a85f94587f882ad584c4473bd7a818d9c3205cec7b6d356d540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.12.15

Release history Release notifications | RSS feed

This release

0.5.0 This release

10 release files

0.4.0

10 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page