Skip to main content

A binary data log library

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

binlog-0.3.0.tar.gz (34.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

binlog-0.3.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.6 MB view details)

Uploaded PyPymanylinux: glibc 2.5+ x86-64

binlog-0.3.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ x86-64

binlog-0.3.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.1 MB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

binlog-0.3.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

binlog-0.3.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.1 MB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

binlog-0.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

binlog-0.3.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.1 MB view details)

Uploaded CPython 3.8macOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

binlog-0.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

binlog-0.3.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (2.1 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

File details

Details for the file binlog-0.3.0.tar.gz.

File metadata

  • Download URL: binlog-0.3.0.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.12

File hashes

Hashes for binlog-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f31dac19cfc175058dd9977a7ec7567de0fad99a6cfe28bd0da38ab472aed235
MD5 761fa4bf7baba41c55f1cb624b7ef470
BLAKE2b-256 a557e9c89b000e55a7061d20c57b3996f2d2351c9c232dc9081a10395693d27b

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f3e2f61d87f2c3c34758dc9fa9ddc42d971d3d7aceba17974461582e9913a83c
MD5 76d0465ede4c501722e92cf3e3cbf281
BLAKE2b-256 e741574119f9511a472e033ad74a3b3e0863a745ef13b7c384ad92a04d941599

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 beab8ec674ba7f21420eda56854df98ccceb6a91dee3259b9a2e2e69acb08ace
MD5 2d05733d33a96aa77896e3491936ee09
BLAKE2b-256 472d162d380bb785a179cc50180e072ef82ba608590d6be548d5515e6cf52185

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d8b0e363047e252eb3a089358afd22651ebce8884b6e3a63e829b0e06ceef085
MD5 478389472e9ecc4dc137aaae261cef52
BLAKE2b-256 5bc8a3d3f974c11189cfe82a13438fe2f8899d732fb5832b4ea13de72113cad2

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cac3151a05373c5a3536ee2229721d29c31b11724f19942f2a8727f3471a0b44
MD5 119bc4d1b8b589900b10bcc06842b014
BLAKE2b-256 5498609d4035d64aa35804d91b40ac0375cb7f61c8823fe43bff7d1a754a31fe

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b568c727fc9c3a4506fa157ae170f7931b1dab311ee54ad2343881f5da3301b4
MD5 dfba7c34f91ce92f25bd060b670f3f26
BLAKE2b-256 7b7c79f2bc58392d175904f528e7e47b075994246146bf5257a86a23f0850316

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7fd3ff95fef9d09540e185ed94e4e3340cf7f6f85c5d96b4e0305616783e68ad
MD5 8b685e3b858baa70bbfe07dd90a394be
BLAKE2b-256 4c126219bc8103b37209eb6f6098207018b3a0682e536f5f11f738646dc72527

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 ff2e67fdd9b3a2a2d5854c7cbafcf000c06a1d5f12a9a874c9517cb4e47c0997
MD5 f19539edd06d55803d6613bc5db514cd
BLAKE2b-256 3353f72ca91ab56ece6b23401820a6ab38a30d0e53c6cfae01c7f3d1915616e4

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 dba7d5343a51450a838b4f60b78485a5b33f9d14ceaf0b407e27768505a72559
MD5 8203668ead792e28933a37c1b7170179
BLAKE2b-256 c88e19b52e64fadf5e36dc2f32eca1f9e3453927b6b66b996aafed98cf37b0aa

See more details on using hashes here.

File details

Details for the file binlog-0.3.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for binlog-0.3.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 264849eb8a15471d913acaefa33222f8c981b4b606d91a3d6e7043c91b4818fa
MD5 97953937ca9dfc21655112025ba757d7
BLAKE2b-256 8fa91e62c3aaca2429fa0749dce99a38f7c5ff7d79bad15b179c233eef1f3da9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page