kurrentdb/lib.rs
1//! Official Rust [KurrentDB] gRPC Client.
2//!
3//! [KurrentDB] is an open-source database built from the ground up for Event Sourcing, with Complex Event Processing in Javascript.
4//!
5//! ## KurrentDB Server Compatibility
6//! This client is compatible with version `20.6.1` upwards and works on Linux, MacOS and Windows.
7//!
8//!
9//! Server setup instructions can be found here [KurrentDB Docs], follow the docker setup for the simplest configuration.
10//!
11//! # Example
12//!
13//! ```no_run
14//! use eventstore::{ Client, EventData };
15//! use serde::{Serialize, Deserialize};
16//!
17//! #[derive(Serialize, Deserialize, Debug)]
18//! struct Foo {
19//! is_rust_a_nice_language: bool,
20//! }
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
24//!
25//! // Creates a client settings for a single node configuration.
26//! let settings = "kurrentdb://admin:changeit@localhost:2113".parse()?;
27//! let client = Client::new(settings)?;
28//!
29//! let payload = Foo {
30//! is_rust_a_nice_language: true,
31//! };
32//!
33//! // It is not mandatory to use JSON as a data format however KurrentDB
34//! // provides great additional value if you do so.
35//! let evt = EventData::json("language-poll", &payload)?;
36//!
37//! let _ = client
38//! .append_to_stream("language-stream", &Default::default(), evt)
39//! .await?;
40//!
41//! let mut stream = client
42//! .read_stream("language-stream", &Default::default())
43//! .await?;
44//!
45//! while let Some(event) = stream.next().await? {
46//! let event = event.get_original_event()
47//! .as_json::<Foo>()?;
48//!
49//! // Do something productive with the result.
50//! println!("{:?}", event);
51//! }
52//!
53//! Ok(())
54//! }
55//! ```
56//! [KurrentDB]: https://eventstore.com/
57//! [eventstoredb docs]: https://developers.eventstore.com/server/20.6/server/installation/
58mod batch;
59mod client;
60mod commands;
61mod event_store;
62mod grpc;
63mod http;
64pub mod operations;
65mod options;
66mod private;
67mod projection_client;
68pub(crate) mod request;
69mod server_features;
70mod types;
71
72pub(crate) mod google {
73 pub mod rpc {
74 pub use super::super::event_store::generated::google_rpc::*;
75 }
76}
77
78pub use batch::*;
79pub use client::Client;
80pub use commands::{PersistentSubscription, ReadEvent, ReadStream, Subscription};
81pub use grpc::{ClientSettings, ClientSettingsParseError};
82pub use options::append_to_stream::*;
83pub use options::batch_append::*;
84pub use options::delete_stream::*;
85pub use options::persistent_subscription::*;
86pub use options::projections::*;
87pub use options::read_all::*;
88pub use options::read_stream::*;
89pub use options::retry::*;
90pub use options::subscribe_to_all::*;
91pub use options::subscribe_to_stream::*;
92pub use options::tombstone_stream::*;
93pub use projection_client::*;
94pub use types::*;
95
96pub mod prelude {
97 pub use crate::batch::*;
98 pub use crate::client::Client;
99 pub use crate::commands::{PersistentSubscription, ReadEvent, ReadStream, Subscription};
100 pub use crate::grpc::{ClientSettings, ClientSettingsParseError};
101 pub use crate::options::append_to_stream::*;
102 pub use crate::options::batch_append::*;
103 pub use crate::options::delete_stream::*;
104 pub use crate::options::persistent_subscription::*;
105 pub use crate::options::projections::*;
106 pub use crate::options::read_all::*;
107 pub use crate::options::read_stream::*;
108 pub use crate::options::retry::*;
109 pub use crate::options::subscribe_to_all::*;
110 pub use crate::options::subscribe_to_stream::*;
111 pub use crate::options::tombstone_stream::*;
112 pub use crate::projection_client::*;
113 pub use crate::types::*;
114}