Exar DB: an event store with streaming support built with Rust

I'm proud to announce my latest release, Exar DB an event store with streaming supports built with Rust.

I'll detail the internal architecture in my next post, but at a glance it is an append-only event store, the events contain an ID (or sequence number), a timestamp, a list of user-defined tags, and the event data/payload.

The events are stored into collections, which are backed by flat files, and serialization is currently pretty basic.

Collection of events can be queried by specifying an offset, an optional maximum number of events to retrieve, an optional tag, and a flag to enable live streaming of events.

The main executable spins up a TCP server with a very simple text-based TCP protocol.

For more in-depth details check back for the next post about its architecture.

If you want to try it out please read the rest of the post.

Modules

The database is split into the following modules:

Installation

Install Cargo, then run:

cargo install exar-db

Starting the database

Simply run exar-db.

Configuring the database

The database can be configured using a TOML configuration file, example below:

log4rs_path = "/path/to/log4rs.toml"
[database]
logs_path = "~/exar-db/data"
scanners = { nr_of_scanners = 2, sleep_time_in_ms = 10 }
[database.collections.my-collection]
routing_strategy = "Random"
scanners = { nr_of_scanners = 4, sleep_time_in_ms = 5 }
[server]
host = "127.0.0.1"
port = 38580
username = "my-username"
password = "my-secret"

Then run Exar DB by specifying the config file location: exar-db --config=/path/to/config.toml.

For more information about the database and server configuration sections, check the documentation about DatabaseConfig and ServerConfig.

Logging

Logging can be configured using a log4rs config file in TOML format, example below:

[appenders.console]
kind = "console"

[appenders.console.encoder]
pattern = "[{d(%+)(local)}] [{h({l})}] [{t}] {m}{n}"

[appenders.file]
kind = "file"
path = "exar-db.log"

[appenders.file.encoder]
pattern = "[{d(%+)(local)}] [{h({l})}] [{t}] {m}{n}"

[root]
level = "info"
appenders = ["console", "file"]

Interacting with the database from Rust

To interact with the database from a rust application use exar-client.

Basic connect/publish/subscribe examples are available at the exar-client section of the documentation.

Interacting with the database via TCP

To interact with the database a very simple TCP protocol can be used even via telnet.

telnet 127.0.0.1 38580

Once the TCP connection has been established, you can use the commands defined in the exar-net section of the documentation.

Exar UI

A simple user interface, built with Electron, useful to interact with the database is available here, but it currently needs to be run from source.