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 on a robot. But should be generally 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(.., 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.2.0.tar.gz (32.8 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.2.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.3 MB view details)

Uploaded PyPymanylinux: glibc 2.5+ x86-64

binlog-0.2.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ x86-64

binlog-0.2.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.8 MB view details)

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

binlog-0.2.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

binlog-0.2.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.8 MB view details)

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

binlog-0.2.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

binlog-0.2.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.8 MB view details)

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

binlog-0.2.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

binlog-0.2.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.8 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.2.0.tar.gz.

File metadata

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

File hashes

Hashes for binlog-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5b5297c786329f55b30f3fdb0a784c16bffe8e6c6397575cd2e8c4a98b2dc342
MD5 fc800edf527d8f681f3ec0baebff0715
BLAKE2b-256 85bf394c3962d7cb0c9400a8a7512d91525a7807c3b16efca9d2c4c3d9ebb63c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for binlog-0.2.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 868cd5c2297184daff6733305e98c9cc2c456c73c3b1e2ba82ac0678e11e4f9d
MD5 eb24171a577d543603aa0acde789a170
BLAKE2b-256 2d4c7fca6ce582dc9103f3b345b52a9cbbaddbbe766953256e81bdda323400da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for binlog-0.2.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f130f2835ee2203199e0baebe4028d714e4689084c8703e6a9d2032478276e66
MD5 3ac7e51739968c545d1b9a8375c45b96
BLAKE2b-256 b1255eb3f84c8cc7ef8a842f4d41992b6066b5551918ff224f4bc489b51e6a5b

See more details on using hashes here.

File details

Details for the file binlog-0.2.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.2.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 cee1a6bb5d008a1e0993d29dc3711caf5c6b81e2170a452b09c14e6c6c3ded45
MD5 b9a19c524b4593d0be9d59ea6f1a9f12
BLAKE2b-256 590ec5e792fdddb676c38c945cfdec71ece1ae8c029400b57172d4bc570a8602

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for binlog-0.2.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e7d9be2c0eb8a2c11c77cad5d313578d288027415617582156da1011bff4dbf9
MD5 3efa0da246f148bae18419cdcbd8bcb3
BLAKE2b-256 a52382d4631b88a339d04edfb950c61b1adda4b030acbe9fd4a67794b0b255bd

See more details on using hashes here.

File details

Details for the file binlog-0.2.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.2.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 112287b06eb0cfed280b47f4bbd547b48aef6925586eca4f0f271b9ab5979f1f
MD5 d5c92f51ec1351d8e1f901c1c1ccdcdc
BLAKE2b-256 3566c32aa1011d03b3c6d2bdcfeba91bfe2a77201e8cfda4c90def34f91e9c92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for binlog-0.2.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 43fe4ac86722815cc2669e2df0573b95651bf5b983bebd2f7aa6655b6f8dbb7f
MD5 a1605c9857e3fbafaf23545f5acffa29
BLAKE2b-256 2944929916016ca11068b7665647bfd00dea28cf0bc0e24890e9ca53cea3643d

See more details on using hashes here.

File details

Details for the file binlog-0.2.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.2.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 7dce09fcde5880667d22bec61bb0743009da2a6c8b4b3242ae8d2d0ce6c68525
MD5 2d926af222b3f7ab8baf0e8ed301784b
BLAKE2b-256 3ce60e5c05f55cdc6c69768ea0e8055cd4a79bd336b8ae979522d9ef69cc53aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for binlog-0.2.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a65972388f9c58042d56262c4ed9b8b5be9ed837621445b68ba0d081288f556a
MD5 40512052277d626443eed35d66de8fc9
BLAKE2b-256 1f43a019a2660ee9d14e8289bb817d64f58d1c8e977e69b91050c0f5511a0489

See more details on using hashes here.

File details

Details for the file binlog-0.2.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.2.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 ec745667ba44d45018e006f43dc2b89c99a0d6602fbfbeed06a5a20cc0d1a1b1
MD5 5557a636393244c2f51c165c337c5675
BLAKE2b-256 3c74ec1fedb56140678aea52c0da17adb9a0bbfcad9ce6e4c8c35c0500879059

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