33 releases

new 0.9.5 Nov 30, 2020
0.9.2 Oct 30, 2020
0.8.0 Jun 30, 2020
0.7.4 Mar 27, 2020
0.1.0 Jun 20, 2018

#58 in Database interfaces

Download history 275/week @ 2020-08-11 233/week @ 2020-08-18 226/week @ 2020-08-25 272/week @ 2020-09-01 268/week @ 2020-09-08 311/week @ 2020-09-15 185/week @ 2020-09-22 203/week @ 2020-09-29 221/week @ 2020-10-06 205/week @ 2020-10-13 247/week @ 2020-10-20 204/week @ 2020-10-27 342/week @ 2020-11-03 152/week @ 2020-11-10 258/week @ 2020-11-17 215/week @ 2020-11-24

1,008 downloads per month
Used in cerberus-es

MIT license

185KB
4.5K SLoC

EventStoreDB Rust Client

Crates.io Crates.io Github action CI workflow Discord Crates.io

Official Rust EventStoreDB gRPC Client.

EventStoreDB is an open-source database built from the ground up for Event Sourcing, with Complex Event Processing in Javascript.

Note: This client is currently under active development and further API changes are expected. Feedback is very welcome.

EventStoreDB Server Compatibility

This client is compatible with version 20.6.1 upwards and works on Linux, MacOS and Windows.

Server setup instructions can be found here EventStoreDB Docs, follow the docker setup for the simplest configuration.

Example

use eventstore::{ EventData, Client, ReadResult };
use futures::stream::TryStreamExt;
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
struct Foo {
    is_rust_a_nice_language: bool,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {

    // Creates a client settings for a single node configuration.
    let settings = "esdb://admin:changeit@localhost:2113".parse()?;
    let client = Client::create(settings).await?;

    let payload = Foo {
        is_rust_a_nice_language: true,
    };

    // It is not mandatory to use JSON as a data format however EventStoreDB
    // provides great additional value if you do so.
    let evt = EventData::json("language-poll", &payload)?;

    let _ = client
        .write_events("language-stream")
        .send_event(evt)
        .await?;

    let result = client
        .read_stream("language-stream")
        .start_from_beginning()
        .read_through()
        .await?;

    if let ReadResult::Ok(mut stream) = result {
        while let Some(event) = stream.try_next().await? {
            let event = event.get_original_event()
                    .as_json::<Foo>()?;
    
            // Do something productive with the result.
            println!("{:?}", event);
        }
    }

    Ok(())
}

Support

Information on support can be found here: EventStoreDB Support

Documentation

Documentation for EventStoreDB can be found here: EventStoreDB Docs

Bear in mind that this client is not yet properly documented. We are working hard on a new version of the documentation.

Community

We have a community discussion space at EventStoreDB Discuss.

Dependencies

~20MB
~431K SLoC