Expand description
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.
§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::{ Client, EventData };
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::new(settings)?;
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
.append_to_stream("language-stream", &Default::default(), evt)
.await?;
let mut stream = client
.read_stream("language-stream", &Default::default())
.await?;
while let Some(event) = stream.next().await? {
let event = event.get_original_event()
.as_json::<Foo>()?;
// Do something productive with the result.
println!("{:?}", event);
}
Ok(())
}
Modules§
Structs§
- Append
ToStream Options - Options of the append to stream command.
- Batch
Append Client - Batch
Append Options - Batch
Write Result - Client
- Represents a client to a single node.
Client
maintains a full duplex communication to EventStoreDB. - Client
Settings - Gathers all the settings related to a gRPC client with an EventStoreDB database.
ClientSettings
can only be created when parsing a connection string. - Client
Settings Parse Error - Create
Projection Options - Credentials
- Holds login and password information.
- Delete
Persistent Subscription Options - Delete
Projection Options - Delete
Stream Options - Options of the delete stream command.
- Endpoint
- Event
Data - Holds data of event about to be sent to the server.
- Generic
Projection Options - GetPersistent
Subscription Info Options - GetResult
Projection Options - GetState
Projection Options - List
Persistent Subscriptions Options - Persistent
Subscription - Persistent
Subscription Connection Info - Persistent
Subscription Info - Persistent
Subscription Measurements - Persistent
Subscription Options - Persistent
Subscription Settings - Gathers every persistent subscription property.
- Persistent
Subscription Stats - Persistent
Subscription ToAll Options - Position
- A structure referring to a potential logical record position in the EventStoreDB transaction file.
- Projection
Client - Projection
Status - Read
AllOptions - Read
Event Result - Represents the result of looking up a specific event number from a stream.
- Read
Stream - Read
Stream Options - Recorded
Event - Represents a previously written event.
- Replay
Parked Messages Options - Resolved
Event - A structure representing a single event or an resolved link event.
- Restart
Persistent Subscription Subsystem - Retry
Options - A command retry policy.
- Stream
Acl - Represents an access control list for a stream.
- Stream
AclBuilder - Stream
Metadata - Represents stream metadata with strongly types properties for system values and a dictionary-like interface for custom values.
- Stream
Metadata Builder - Used to facilitate the creation of a stream’s metadata.
- Streaming
- Subscribe
ToAll Options - Subscribe
ToPersistent Subscription Options - Subscribe
ToStream Options - Subscription
- Subscription
Filter - Tombstone
Stream Options - Options of the tombstone stream command.
- Update
Projection Options - Versioned
Metadata - Represents a stream metadata.
- Write
Result - Returned after writing to a stream.
- Wrong
Expected Version
Enums§
- Acl
- Current
Revision - Actual revision of a stream.
- Error
- EventStoreDB command error.
- Expected
Revision - Constants used for expected version control. The use of expected version can be a bit tricky especially when discussing assurances given by the GetEventStore server.
- Grpc
Connection Error - EventStoreDB command error.
- NakAction
- Gathers every possible Nak actions.
- Node
Preference - Indicates which order of preferred nodes for connecting to.
- Persist
Action Error - Enumerates all persistent action exceptions.
- Persist
Action Result - Represents the different scenarios that could happen when performing a persistent subscription.
- Persistent
Subscription Event - Read
Event - Read
Event Status - Enumeration detailing the possible outcomes of reading a stream.
- Read
Stream Error - Represents the errors that can arise when reading a stream.
- Read
Stream Status - Represents the result of reading a stream.
- Retry
- Represents a reconnection strategy when a connection has dropped or is about to be created.
- Revision
OrPosition - Stream
Metadata Result - Represents stream metadata as a series of properties for system data and user-defined metadata.
- Stream
Position - Subscription
Event - Events related to a subscription.
- System
Consumer Strategy - System supported consumer strategies for use with persistent subscriptions.