Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ commands:
- run:
name: Run mock tests
command: cargo test --lib --features "mocks i-keys" --no-default-features
test_doctets:
steps:
- run:
name: Run doctests
command: cargo test --doc --features subscriber-client,i-cluster,i-client
test_default_features:
steps:
- checkout
Expand Down Expand Up @@ -240,6 +245,7 @@ jobs:
steps:
- checkout
- build_docs
- test_doctests
- test_mocks
- run:
name: Check partial tracing
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ An async client for Valkey and Redis

## Example

```rust
```rust,no_run
use fred::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Error> {
let config = Config::from_url("redis://localhost:6379/1")?;
let client = Builder::from_config(config)
.with_connection_config(|config| {
config.connection_timeout = Duration::from_secs(5);
config.connection_timeout = std::time::Duration::from_secs(5);
config.tcp = TcpConfig {
nodelay: Some(true),
..Default::default()
Expand All @@ -36,8 +36,8 @@ async fn main() -> Result<(), Error> {
// convert responses to many common Rust types
let foo: Option<String> = client.get("foo").await?;
assert!(foo.is_none());
let _: () = client.set("foo", "bar", None, None, false).await?;

client.set("foo", "bar", None, None, false).await?;
// or use turbofish to declare response types
println!("Foo: {:?}", client.get::<String, _>("foo").await?);

Expand Down
6 changes: 3 additions & 3 deletions src/clients/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ impl Client {
/// # use fred::prelude::*;
/// async fn example(client: &Client) -> Result<(), Error> {
/// // discover servers via the `Config` or active connections
/// let connections = client.active_connections().await?;
/// let connections = client.active_connections();
///
/// // ping each node in the cluster individually
/// for server in connections.into_iter() {
/// for server in connections {
/// let _: () = client.with_cluster_node(server).ping(None).await?;
/// }
///
Expand All @@ -339,7 +339,7 @@ impl Client {
/// .expect("Failed to read cached cluster state")
/// .unique_primary_nodes();
///
/// for server in servers.into_iter() {
/// for server in servers {
/// // verify the server address with `CLIENT INFO`
/// let server_addr = client
/// .with_cluster_node(&server)
Expand Down
2 changes: 1 addition & 1 deletion src/clients/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ struct ExclusivePoolInner {
///
/// This interface can be used when callers require exclusive ownership over the connection. For example,
///
/// ```no_run no_compile
/// ```text
/// WATCH foo
/// foo = GET foo
/// if foo > 1:
Expand Down
4 changes: 4 additions & 0 deletions src/modules/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ macro_rules! impl_unsigned_number (
/// ```rust
/// # use fred::types::Value;
/// # use std::collections::HashMap;
/// # fn test() -> Result<(), Box<dyn std::error::Error>> {
/// let foo: usize = Value::String("123".into()).convert()?;
/// let foo: i64 = Value::String("123".into()).convert()?;
/// let foo: String = Value::String("123".into()).convert()?;
Expand All @@ -150,6 +151,7 @@ macro_rules! impl_unsigned_number (
/// let foo: Vec<(String, i64)> =
/// Value::Array(vec!["a".into(), 1.into(), "b".into(), 2.into()]).convert()?;
/// // ...
/// # Ok(()) }
/// ```
///
/// ## Bulk Values
Expand All @@ -162,12 +164,14 @@ macro_rules! impl_unsigned_number (
///
/// ```rust
/// # use fred::types::Value;
/// # fn test() -> Result<(), Box<dyn std::error::Error>> {
/// let _: String = Value::Array(vec![]).convert()?; // error
/// let _: String = Value::Array(vec!["a".into()]).convert()?; // "a"
/// let _: String = Value::Array(vec!["a".into(), "b".into()]).convert()?; // error
/// let _: Option<String> = Value::Array(vec![]).convert()?; // None
/// let _: Option<String> = Value::Array(vec!["a".into()]).convert()?; // Some("a")
/// let _: Option<String> = Value::Array(vec!["a".into(), "b".into()]).convert()?; // error
/// # Ok(()) }
/// ```
///
/// ## The `default-nil-types` Feature Flag
Expand Down