-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* URL parsing into `RedisConfig` * Change `bzpopmin` and `bzpopmax` return value types * Bug fixes * Remove unimplemented mocks feature
- Loading branch information
Showing
21 changed files
with
712 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "fred" | ||
version = "5.0.0-beta.1" | ||
version = "5.0.0" | ||
authors = ["Alec Embke <[email protected]>"] | ||
edition = "2018" | ||
description = "An async Redis client for Rust built on Futures and Tokio." | ||
|
@@ -86,7 +86,6 @@ metrics = [] | |
ignore-auth-error = [] | ||
enable-tls = ["native-tls", "tokio-native-tls"] | ||
vendored-tls = ["enable-tls", "native-tls/vendored"] | ||
mocks = [] | ||
reconnect-on-auth-error = [] | ||
pool-prefer-active = [] | ||
full-tracing = ["partial-tracing", "tracing", "tracing-futures"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ const DATABASE: u8 = 2; | |
|
||
#[tokio::main] | ||
async fn main() -> Result<(), RedisError> { | ||
// example showing how to parse a redis URL (from an environment variable, etc) | ||
// see the `RedisConfig::from_url` function documentation for more information | ||
let config = RedisConfig::from_url("redis://username:[email protected]:6379/1")?; | ||
|
||
// example showing a full kitchen sink configuration | ||
// use `..Default::default` to fill in defaults wherever needed | ||
let config = RedisConfig { | ||
|
@@ -16,15 +20,15 @@ async fn main() -> Result<(), RedisError> { | |
server: ServerConfig::new_centralized("127.0.0.1", 6379), | ||
// how to handle commands sent while a connection is blocked | ||
blocking: Blocking::Block, | ||
// an optional username, if using ACL rules | ||
// an optional username, if using ACL rules. use "default" if you need to specify a username but have not configured ACL rules. | ||
username: None, | ||
// an optional authentication key or password | ||
password: None, | ||
// optional TLS settings | ||
// optional TLS settings (requires the `enable-tls` feature) | ||
tls: None, | ||
// whether to enable tracing | ||
// whether to enable tracing (only used with `partial-tracing` or `full-tracing` features) | ||
tracing: false, | ||
// the protocol version to use | ||
// the protocol version to use. note: upgrading an existing codebase to RESP3 can be non-trivial. be careful. | ||
version: RespVersion::RESP2, | ||
// the database to automatically select after connecting or reconnecting | ||
database: Some(DATABASE), | ||
|
@@ -36,7 +40,7 @@ async fn main() -> Result<(), RedisError> { | |
max_feed_count: 1000, | ||
// a default timeout to apply to all commands (0 means no timeout) | ||
default_command_timeout_ms: 0, | ||
// the amount of time to wait before syncing cluster state after a MOVED or ASK error | ||
// the amount of time to wait before rebuilding the client's cached cluster state after a MOVED or ASK error. | ||
cluster_cache_update_delay_ms: 10, | ||
// the maximum number of times to retry commands when connections close unexpectedly | ||
max_command_attempts: 3, | ||
|
@@ -59,15 +63,14 @@ async fn main() -> Result<(), RedisError> { | |
|
||
// run a function when the connection closes unexpectedly | ||
tokio::spawn(client.on_error().for_each(|e| async move { | ||
println!("Client received connection error: {:?}", e); | ||
println!("Client disconnected with error: {:?}", e); | ||
})); | ||
// run a function whenever the client reconnects | ||
tokio::spawn(client.on_reconnect().for_each(move |client| async move { | ||
println!("Client {} reconnected.", client.id()); | ||
Ok(()) | ||
})); | ||
|
||
let _ = client.connect(Some(policy)); | ||
let connection_task = client.connect(Some(policy)); | ||
let _ = client.wait_for_connect().await?; | ||
|
||
// declare types on response values | ||
|
@@ -82,11 +85,12 @@ async fn main() -> Result<(), RedisError> { | |
println!("Foo: {:?}", client.get::<String, _>("foo").await?); | ||
|
||
// update performance config options as needed | ||
client.update_perf_config(PerformanceConfig { | ||
max_command_attempts: 100, | ||
..Default::default() | ||
}); | ||
let mut perf_config = client.client_config().performance; | ||
perf_config.max_command_attempts = 100; | ||
client.update_perf_config(perf_config); | ||
|
||
let _ = client.quit().await?; | ||
// or manage the connection task directly if needed. however, calling `quit` or `shutdown` also ends the connection task. | ||
connection_task.abort(); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.