#usr-local #sourisdb #souris

no-std sourisdb

Database format focused on compression size without using external libraries

4 releases

0.2.1 Oct 24, 2024
0.2.0 Oct 18, 2024
0.1.1 Oct 8, 2024
0.1.0 Oct 7, 2024

#1386 in Database interfaces


Used in 2 crates

MIT license

1MB
4K SLoC

Souris

wakatime

A tiny no_std database designed to minimise size over all else. If you're using sourisd, then it's also all stored in-memory for ultimate speed!

Named after mice, because they're tiny.

Usage

Use the sourisd service to run a daemon on your local machine, and then souris to modify local databases or to modify sourisd databases.

NB:

This project is currently not far off being finished but also not that close. I also have a major problem with endless scope creep (which in fairness, isn't really a problem if I'm learning new things).

Running of sourisd

You can either make a directory for the data (eg. mkdir data && chmod 777 data) and docker compose like this example:

services:
  watchtower:
    image: containrrr/watchtower
    command:
      - "--label-enable"
      - "--interval"
      - "30"
      - "--rolling-restart"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  souris:
    image: ghcr.io/burntnail/sourisd:latest
    restart: always
    environment:
      - RUST_LOG=info
      - BASE_LOCATION=/sourisdata/
    volumes:
      - ./data:/sourisdata/
    labels:
      - "com.centurylinklabs.watchtower.enable=true"
    ports:
      - "7687:7687"
    expose:
      - 7687

This one conveniently includes watchtower, and so will auto-restart and update whenever the docker image is updated.

Or build it locally and use something like this systemd file:

[Unit]
Description=SourisDB Daemon
After=multi-user.target

[Service]
ExecStart=/usr/local/bin/sourisd
Type=simple
Restart=on-failure
Environment="RUST_LOG=trace"

[Install]
WantedBy=default.target

To use the systemd file, I put this into /etc/systemd/system/sourisd.service, then ran a quick sudo systemctl daemon-reload && sudo systemctl enable --now sourisd.


lib.rs:

sourisdb is a crate designed to provide a size-optimised way of transmitting a key-value store. There are a variety of methods used to achieve this goal ranging from variable-size integers to niche optimisations all detailed within values::Value.

The expected use-case is for web - in testing I've found this to be far more efficient than JSON whilst preserving type information AND providing additional types. Typically, SourisDB stores take around 25% less space than JSON objects even when minified.

sourisdb can also be used for storage on-disk as it is entirely byte-order-agnostic as it deliberately stores everything using little-endian bytes.

Dependencies

~4–16MB
~188K SLoC