1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! # Amazon's QLDB Driver
//!
//! Driver for Amazon's QLDB Database implemented in pure rust.
//!
//! [](https://docs.rs/qldb)
//! [](https://crates.io/crates/qldb)
//! [](https://github.com/Couragium/qldb-rs/actions/workflows/rust.yml)
//!
//! The driver is fairly tested and should be ready to test in real projects.
//!
//! ## Example
//!
//! ```rust,no_run
//! use qldb::QldbClient;
//! use std::collections::HashMap;
//! # use eyre::Result;
//!
//! # async fn test() -> Result<()> {
//! let client = QldbClient::default("rust-crate-test", 200).await?;
//!
//! let mut value_to_insert = HashMap::new();
//! // This will insert a documents with a key "test_column"
//! // with the value "IonValue::String(test_value)"
//! value_to_insert.insert("test_column", "test_value");
//!
//! client
//! .transaction_within(|client| async move {
//! client
//! .query("INSERT INTO TestTable VALUE ?")
//! .param(value_to_insert)
//! .execute()
//! .await?;
//! Ok(())
//! })
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! # Session Pool
//!
//! The driver has a session pool. The second parameter in the
//! QldbClient::default is the maximum size of the connection pool.
//!
//! The pool will be auto-populated as parallel transaction are being
//! requested until it reaches the provided maximum.
//!
//! The pool uses one independent thread with a single-threaded
//! executor ([async-executor](https://crates.io/crates/async-executor))
//! in order to be able to spawn tasks after the session has been returned.
//!
//! ## Alternative session Pool
//!
//! There is an alternative session pool that will require an spawner
//! function to be provided. It allows to have the pool running by using
//! the spawn function of the executor you use. We tested async-std and
//! tokio, but others should work as well.
//!
//! This pool will spawn two internal tasks handling the pool.
//!
//! Use this if you want for this driver to not create a new thread.
//!
//! Example with async-std:
//!
//! ```rust,no_run
//! use qldb::QldbClient;
//! use std::sync::Arc;
//! # use eyre::Result;
//!
//! # async fn test() -> Result<()> {
//! let client = QldbClient::default_with_spawner(
//! "rust-crate-test",
//! 200,
//! Arc::new(move |fut| {async_std::task::spawn(Box::pin(fut));})
//! )
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! Or, with tokio:
//!
//! ```rust,no_run
//! use qldb::QldbClient;
//! use std::sync::Arc;
//! # use eyre::Result;
//!
//! # async fn test() -> Result<()> {
//! let client = QldbClient::default_with_spawner(
//! "rust-crate-test",
//! 200,
//! Arc::new(move |fut| {tokio::spawn(Box::pin(fut));})
//! )
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Select the pool you want to use
//!
//! By default, both pools are available by using the methods `QldbClient::default`
//! and `QldbClient::default_with_spawner`. If you don't want the pool to be available
//! in runtime, you can disable by removing the default features. Still, you will
//! need to add at least one feature to enable one pool.
//!
//! This will only enable the default pool, the one that uses one thread.
//! ```toml,no_code
//! qldb = { version = "3", default_features = false, features = ["internal_pool_with_thread"]}
//! ```
//!
//! This will only enable the alternative pool, the one that requires an spawner
//! ```toml,no_code
//! qldb = { version = "3", default_features = false, features = ["internal_pool_with_spawner"]}
//! ```
//!
//! # Underlying Ion Format Implementation
//!
//! The library uses [ion-binary-rs](https://crates.io/crates/ion-binary-rs),
//! which is our own, pure rust, implementation of the format. It is very
//! well tested and ready to use in production too.
//!
//! # Test
//!
//! For tests you will need to have some AWS credentials in your
//! PC (as env variables or in ~/.aws/credentials). There needs
//! to be a QLDB database with the name "rust-crate-test" in the
//! aws account. The tests need to be run sequentially, so in order
//! to run the tests please run the following command:
//!
//! ```sh
//! RUST_TEST_THREADS=1 cargo test
//! ```
pub use QldbClient;
pub use Cursor;
pub use Document;
pub use DocumentCollection;
pub use ion_binary_rs as ion;
pub use QueryBuilder;
pub use Region;
pub use Transaction;
pub use ;
pub use ;