Skip to content

Commit

Permalink
7.0.0 (#172)
Browse files Browse the repository at this point in the history
* feat: added a new client builder and configuration interface
* feat: reworked or removed the majority of the `globals` interface
* feat: support multiple IP addresses in the `Resolve` interface
* feat: add `with_options` command configuration interface
* feat: replaced the `no-client-setname` feature flag with `auto-client-setname`
* fix: redesign the connection timeout configuration interface
* feat: add an interface to configure TCP socket options
* fix: removed the automatic `serde_json::Value` -> `RedisValue` type conversion logic
* fix: implement `ClientLike` for `RedisPool` 
* feat: moved and refactored the `on_*` functions into a new `EventInterface`
* fix: fixed several bugs with the `Replica` routing implementation
* fix: fixed several bugs and inconsistencies related to parsing single-element arrays
* fix: changed several `FromRedis` type conversion rules
* feat: add a RedisJSON interface
* feat: add a RESP2 and RESP3 codec interface
* fix: all commands now return generic types

---------

Co-authored-by: Rob Day <[email protected]>
  • Loading branch information
aembke and rkday-pro authored Oct 6, 2023
1 parent a9bf850 commit a62d8c9
Show file tree
Hide file tree
Showing 185 changed files with 7,788 additions and 5,612 deletions.
2 changes: 1 addition & 1 deletion .circleci/Dockerfile.sentinel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# note: the top level target directory must be removed prior to running this

FROM cimg/rust:1.72.0
FROM cimg/rust:1.72.1
USER circleci

ARG REDIS_VERSION
Expand Down
125 changes: 69 additions & 56 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ commands:
- run:
name: Build documentation
command: tests/doc.sh
test_mocks:
steps:
- run:
name: Run mock tests
command: cargo test --lib --features mocks --no-default-features
test_default_features:
steps:
- checkout
Expand All @@ -50,6 +55,14 @@ commands:
name: Run tests with all features
command: source tests/environ && tests/runners/all-features.sh
- save-cargo-deps-cache
test_redis_stack:
steps:
- checkout
- restore-cargo-deps-cache
- run:
name: Run tests with redis-stack features
command: source tests/environ && tests/runners/redis-stack.sh
- save-cargo-deps-cache
test_no_features:
steps:
- checkout
Expand Down Expand Up @@ -82,122 +95,122 @@ commands:
name: Run cluster tests with rustls features
command: source tests/environ && tests/scripts/tls-creds.sh && tests/runners/cluster-rustls.sh
- save-cargo-deps-cache
test_default_nil_types_features:
steps:
- checkout
- restore-cargo-deps-cache
- run:
name: Run tests with default-nil-types features
command: source tests/environ && tests/runners/default-nil-types.sh
- save-cargo-deps-cache

jobs:
test-default-7_0:
test-default-nil-types-7_2:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 7.0.9
REDIS_VERSION: 7.2.1
steps:
- test_default_features
test-no-features-7_0:
- test_default_nil_types_features
test-default-7_2:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 7.0.9
REDIS_VERSION: 7.2.1
steps:
- test_no_features
test-all-features-7_0:
- test_default_features
test-redis-stack-7_2:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 7.0.9
REDIS_VERSION: 7.2.1
steps:
- test_all_features
test-cluster-tls-features-7_0:
- test_redis_stack
test-no-features-7_2:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 7.0.9
FRED_CI_TLS: true
REDIS_VERSION: 7.2.1
steps:
- test_tls_cluster
test-cluster-rustls-features-7_0:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 7.0.9
FRED_CI_TLS: true
steps:
- test_rustls_cluster
test-default-6_2:
- test_no_features
test-all-features-7_2:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 6.2.2
REDIS_VERSION: 7.2.1
steps:
- test_default_features
test-no-features-6_2:
- test_all_features
test-cluster-tls-features-7_2:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 6.2.2
REDIS_VERSION: 7.2.1
FRED_CI_TLS: true
steps:
- test_no_features
test-all-features-6_2:
- test_tls_cluster
test-cluster-rustls-features-7_2:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 6.2.2
REDIS_VERSION: 7.2.1
FRED_CI_TLS: true
steps:
- test_all_features
test-sentinel-6_2:
- test_rustls_cluster
test-sentinel-7_2:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
environment:
REDIS_VERSION: 6.2.2
REDIS_VERSION: 7.2.1
steps:
- test_sentinel
test-sentinel-7_0:
machine:
image: ubuntu-2204:2022.10.2
docker_layer_caching: true
resource_class: medium
test-misc:
docker:
- image: cimg/rust:1.72.1
environment:
REDIS_VERSION: 7.0.9
CARGO_NET_GIT_FETCH_WITH_CLI: true
steps:
- test_sentinel
test-docs:
- checkout
- build_docs
- test_mocks
clippy-lint:
docker:
- image: cimg/rust:1.72.0
- image: cimg/rust:1.72.1
environment:
CARGO_NET_GIT_FETCH_WITH_CLI: true
steps:
- checkout
- build_docs
- run:
name: Clippy
command: cargo clippy -- -Dwarnings


workflows:
version: 2
build:
jobs:
# the older bitnami Redis images require a different process to bootstrap ACL rules...
#- test-default-6_2
#- test-all-features-6_2
#- test-no-features-6_2
#- test-sentinel-6_2
- test-default-7_0
- test-all-features-7_0
- test-no-features-7_0
- test-sentinel-7_0
- test-docs
- test-cluster-tls-features-7_0
- test-cluster-rustls-features-7_0
- test-default-7_2
- test-all-features-7_2
- test-no-features-7_2
- test-default-nil-types-7_2
- test-redis-stack-7_2
- test-sentinel-7_2
- test-misc
- test-cluster-tls-features-7_2
- test-cluster-rustls-features-7_2
- clippy-lint
47 changes: 40 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
## 7.0.0

* Added a new client [builder](src/types/builder.rs) and configuration interface.
* Reworked or removed the majority of the `globals` interface.
* Support multiple IP addresses in the `Resolve` interface.
* Add `with_options` command configuration interface.
* Replaced the `no-client-setname` feature flag with `auto-client-setname`.
* Add an interface to configure TCP socket options.
* Removed the automatic `serde_json::Value` -> `RedisValue` type conversion logic.
* This unintentionally introduced some ambiguity on certain interfaces.
* The `RedisValue` -> `serde_json::Value` type conversion logic was not changed.
* Reworked the majority of the `RedisPool` interface.
* Moved and refactored the `on_*` functions into a new `EventInterface`.
* Fixed bugs with the `Replica` routing implementation.
* Fixed bugs related to parsing single-element arrays.
* Changed several `FromRedis` type conversion rules. See below or the `FromRedis` docs for more information.
* Add a [RedisJSON](https://github.com/RedisJSON/RedisJSON/) interface.
* Add a RESP2 and RESP3 codec interface.

### Upgrading from 6.x

Notable interface changes:

* `ArcStr` has been replaced with `bytes_utils::Str`.
* Timeout arguments or fields now all use `std::time::Duration`.
* Many of the old global or performance config values can now be set on individual commands via the `with_options` interface.
* The `RedisPool` interface now directly implements `ClientLike` rather than relying on `Deref` shenanigans.
* The `on_*` event functions were moved and renamed. Reconnection events now include the associated `Server`.
* The `tls_server_name` field on `Server` is now properly gated by the TLS feature flags.
* Mocks are now optional even when the feature flag is enabled.

Notable implementation Changes:

* `Pipeline` and `Transaction` structs can now be reused. Calling `exec`, `all`, `last`, or `try_all` no longer drains the inner command buffer.
* Many of the default timeout values have been lowered significantly, often from 60 sec to 10 sec.
* In earlier versions the `FromRedis` trait implemented a few inconsistent or ambiguous type conversions policies.
* Most of these were consolidated under the `default-nil-types` feature flag.
* It is recommended that callers review the updated `FromRedis` docs or see the unit tests in [responses](src/modules/response.rs).
* The `connect` function can now be called more than once to force reset all client state.

## 6.3.2

* Fix a bug with connection errors unexpectedly ending the connection task.
Expand All @@ -15,13 +55,6 @@
* Fix compilation error with `full-tracing`
* Support `Vec<(T1, T2, ...)>` with `FromRedis`

## 6.2.2

* Fix cluster replica discovery with Elasticache
* Fix cluster replica `READONLY` usage
* Fix compilation error with `full-tracing`
* Support `Vec<(T1, T2, ...)>` with `FromRedis`

## 6.2.1

* Fix cluster failover with paused nodes
Expand Down
17 changes: 8 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ This document gives some background on how the library is structured and how to
# General

* Use 2 spaces instead of tabs.
* Run rustfmt before submitting any changes.
* Run rustfmt and clippy before submitting any changes.
* Clean up any compiler warnings.
* Use the `async` syntax rather than `impl Future` where possible.

## Branches

* Create external PRs against the `staging` branch.
* Please create external PRs against the `staging` branch.
* Use topic branches with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).
* Branching strategy is `<topic>` -> (squash) `staging` -> `main` -> `release-<major version>`
* Remove `chore` commits when squashing PRs.

## TODO List

Expand Down Expand Up @@ -54,7 +52,7 @@ impl RedisCommandKind {

// ..

pub fn to_str_debug(&self) -> &'static str {
pub fn to_str_debug(&self) -> &str {
match *self {
// ..
RedisCommandKind::Mget => "MGET",
Expand All @@ -64,7 +62,7 @@ impl RedisCommandKind {

// ..

pub fn cmd_str(&self) -> &'static str {
pub fn cmd_str(&self) -> Str {
match *self {
// ..
RedisCommandKind::Mget => "MGET"
Expand All @@ -80,10 +78,11 @@ impl RedisCommandKind {

```rust
pub async fn mget<C: ClientLike>(client: &C, keys: MultipleKeys) -> Result<RedisValue, RedisError> {
// maybe do some kind of validation
utils::check_empty_keys(&keys)?;

let frame = utils::request_response(client, move || {
// time spent here will show up in traces
// time spent here will show up in traces in the `prepare_command` span
Ok((RedisCommandKind::Mget, keys.into_values()))
})
.await?;
Expand All @@ -92,7 +91,7 @@ pub async fn mget<C: ClientLike>(client: &C, keys: MultipleKeys) -> Result<Redis
}
```

Or use one of the shorthand helper functions.
Or use one of the shorthand helper functions or macros.

```rust
pub async fn mget<C: ClientLike>(client: &C, keys: MultipleKeys) -> Result<RedisValue, RedisError> {
Expand Down Expand Up @@ -121,7 +120,7 @@ pub trait KeysInterface: ClientLike {
K: Into<MultipleKeys> + Send,
{
into!(keys);
commands::keys::mget(self, keys).await
commands::keys::mget(self, keys).await?.convert()
}
// ...
}
Expand Down
Loading

0 comments on commit a62d8c9

Please sign in to comment.