Skip to content

Commit 5c63b94

Browse files
committed
Add pipeline examples and bump version
1 parent c4eefe8 commit 5c63b94

File tree

6 files changed

+65
-19
lines changed

6 files changed

+65
-19
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "Apache-2.0"
99
name = "skytable"
1010
readme = "README.md"
1111
repository = "https://github.com/skytable/client-rust"
12-
version = "0.6.2-alpha.1"
12+
version = "0.6.2-alpha.2"
1313

1414
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1515

@@ -26,13 +26,13 @@ sync = []
2626

2727
[dependencies]
2828
bytes = { version = "1.1.0", optional = true }
29-
openssl = { version = "0.10.36", optional = true }
30-
tokio = { version = "1.12.0", features = [
29+
openssl = { version = "0.10.38", optional = true }
30+
tokio = { version = "1.13.0", features = [
3131
"net",
3232
"io-util",
3333
"io-std",
3434
], optional = true }
35-
tokio-openssl = { version = "0.6.2", optional = true }
35+
tokio-openssl = { version = "0.6.3", optional = true }
3636
[package.metadata.docs.rs]
3737
all-features = true
3838
rustdoc-args = ["--cfg", "docsrs"]

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cargo new skyapp
2626
First add this to your `Cargo.toml` file:
2727

2828
```toml
29-
skytable = "0.6.2-alpha.1"
29+
skytable = "0.6.2-alpha.2"
3030
```
3131

3232
Now open up your `src/main.rs` file and establish a connection to the server while also adding some
@@ -118,7 +118,7 @@ You can also find the [latest examples here](https://github.com/skytable/client-
118118
If you need to use an `async` API, just change your import to:
119119

120120
```toml
121-
skytable = { version = "0.6.2-alpha.1", features=["async"], default-features = false }
121+
skytable = { version = "0.6.2-alpha.2", features=["async"], default-features = false }
122122
```
123123

124124
You can now establish a connection by using `skytable::AsyncConnection::new()`, adding `.await`s wherever
@@ -130,7 +130,7 @@ With this client driver, it is possible to use both sync and `async` APIs **at t
130130
this, simply change your import to:
131131

132132
```toml
133-
skytable = { version="0.6.2-alpha.1", features=["sync", "async"] }
133+
skytable = { version="0.6.2-alpha.2", features=["sync", "async"] }
134134
```
135135

136136
## TLS
@@ -140,15 +140,15 @@ If you need to use TLS features, this crate will let you do so with OpenSSL.
140140
### Using TLS with sync interfaces
141141

142142
```toml
143-
skytable = { version="0.6.2-alpha.1", features=["sync","ssl"] }
143+
skytable = { version="0.6.2-alpha.2", features=["sync","ssl"] }
144144
```
145145

146146
You can now use the async `sync::TlsConnection` object.
147147

148148
### Using TLS with async interfaces
149149

150150
```toml
151-
skytable = { version="0.6.2-alpha.1", features=["async","aio-ssl"], default-features=false }
151+
skytable = { version="0.6.2-alpha.2", features=["async","aio-ssl"], default-features=false }
152152
```
153153

154154
You can now use the async `aio::TlsConnection` object.

src/actions.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ implement_actions! {
197197
}
198198
/// Get multiple keys
199199
///
200-
/// This returns a [`SimpleArray`] of values for the provided keys
201-
///
202200
/// This is equivalent to:
203201
/// ```text
204202
/// MGET <k1> <k2> ...

src/aio.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ macro_rules! impl_async_methods {
5858
RawResponse::PipelinedQuery(_) => Err(SkyhashError::InvalidResponse.into()),
5959
}
6060
}
61+
/// Runs a pipelined query. See the [`Pipeline`](Pipeline) documentation for a guide on
62+
/// usage
6163
pub async fn run_pipeline(&mut self, pipeline: Pipeline) -> SkyRawResult<Vec<Element>> {
6264
match self._run_query(&pipeline).await? {
6365
RawResponse::PipelinedQuery(pq) => Ok(pq),

src/lib.rs

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
//!
3939
//! First add this to your `Cargo.toml` file:
4040
//! ```toml
41-
//! skytable = "0.6.2-alpha.1"
41+
//! skytable = "0.6.2-alpha.2"
4242
//! ```
4343
//! Now open up your `src/main.rs` file and establish a connection to the server while also adding some
4444
//! imports:
@@ -125,7 +125,7 @@
125125
//!
126126
//! If you need to use an `async` API, just change your import to:
127127
//! ```toml
128-
//! skytable = { version = "0.6.2-alpha.1", features=["async"], default-features=false }
128+
//! skytable = { version = "0.6.2-alpha.2", features=["async"], default-features=false }
129129
//! ```
130130
//! You can now establish a connection by using `skytable::AsyncConnection::new()`, adding `.await`s wherever
131131
//! necessary. Do note that you'll the [Tokio runtime](https://tokio.rs).
@@ -135,7 +135,7 @@
135135
//! With this client driver, it is possible to use both sync and `async` APIs **at the same time**. To do
136136
//! this, simply change your import to:
137137
//! ```toml
138-
//! skytable = { version="0.6.2-alpha.1", features=["sync", "async"] }
138+
//! skytable = { version="0.6.2-alpha.2", features=["sync", "async"] }
139139
//! ```
140140
//!
141141
//! ## TLS
@@ -144,13 +144,13 @@
144144
//!
145145
//! ### Using TLS with sync interfaces
146146
//! ```toml
147-
//! skytable = { version="0.6.2-alpha.1", features=["sync","ssl"] }
147+
//! skytable = { version="0.6.2-alpha.2", features=["sync","ssl"] }
148148
//! ```
149149
//! You can now use the async [TlsConnection](`sync::TlsConnection`) object.
150150
//!
151151
//! ### Using TLS with async interfaces
152152
//! ```toml
153-
//! skytable = { version="0.6.2-alpha.1", features=["async","aio-ssl"], default-features=false }
153+
//! skytable = { version="0.6.2-alpha.2", features=["async","aio-ssl"], default-features=false }
154154
//! ```
155155
//! You can now use the async [TlsConnection](`aio::TlsConnection`) object.
156156
//!
@@ -608,7 +608,52 @@ cfg_dbg!(
608608
/// # Pipeline
609609
///
610610
/// A pipeline is a way of queing up multiple queries, sending them to the server at once instead of sending them individually, avoiding
611-
/// round-trip-times while also simplifying usage in several places. Responses are returned in the order they are sent
611+
/// round-trip-times while also simplifying usage in several places. Responses are returned in the order they are sent.
612+
///
613+
/// ## Example with the sync API
614+
///
615+
/// ```no_run
616+
/// use skytable::{query, Pipeline, Element, RespCode};
617+
/// use skytable::sync::Connection;
618+
///
619+
/// let mut con = Connection::new("127.0.0.1", 2003).unwrap();
620+
/// let pipe = Pipeline::new()
621+
/// .add(query!("set", "x", "100"))
622+
/// .add(query!("heya", "echo me!"));
623+
///
624+
/// let ret = con.run_pipeline(pipe).unwrap();
625+
/// assert_eq!(
626+
/// ret,
627+
/// vec![
628+
/// Element::RespCode(RespCode::Okay),
629+
/// Element::String("echo me!".to_owned())
630+
/// ]
631+
/// );
632+
/// ```
633+
///
634+
/// ## Example with the async API
635+
///
636+
/// ```no_run
637+
/// use skytable::{query, Pipeline, Element, RespCode};
638+
/// use skytable::aio::Connection;
639+
///
640+
/// async fn run() {
641+
/// let mut con = Connection::new("127.0.0.1", 2003).await.unwrap();
642+
/// let pipe = Pipeline::new()
643+
/// .add(query!("set", "x", "100"))
644+
/// .add(query!("heya", "echo me!"));
645+
///
646+
/// let ret = con.run_pipeline(pipe).await.unwrap();
647+
/// assert_eq!(
648+
/// ret,
649+
/// vec![
650+
/// Element::RespCode(RespCode::Okay),
651+
/// Element::String("echo me!".to_owned())
652+
/// ]
653+
/// );
654+
/// }
655+
/// ```
656+
///
612657
pub struct Pipeline {
613658
len: usize,
614659
chain: Vec<u8>,
@@ -633,6 +678,7 @@ impl Pipeline {
633678
self.len += 1;
634679
query.write_query_to_writable(&mut self.chain);
635680
}
681+
/// Returns the number of queries in the pipeline
636682
pub fn len(&self) -> usize {
637683
self.len
638684
}

src/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ macro_rules! impl_sync_methods {
5555
RawResponse::PipelinedQuery(_) => Err(SkyhashError::InvalidResponse.into()),
5656
}
5757
}
58-
/// This function will write a pipelined query to the stream and read the response from the server,
59-
/// returning errors if they do occur.
58+
/// Runs a pipelined query. See the [`Pipeline`](Pipeline) documentation for a guide on
59+
/// usage
6060
pub fn run_pipeline(&mut self, pipeline: Pipeline) -> SkyRawResult<Vec<Element>> {
6161
assert!(pipeline.len() != 0, "A `Pipeline` cannot be empty!");
6262
match self._run_query(&pipeline)? {

0 commit comments

Comments
 (0)