Skip to content

Release 0.2.0 — RedisCache API change, manual publish gate - #1

Closed
kings0x wants to merge 3 commits into
mainfrom
release-0.2.0
Closed

kings0x wants to merge 3 commits into
mainfrom
release-0.2.0

Conversation

@kings0x

@kings0x kings0x commented Jul 11, 2026 •

Copy link
Copy Markdown
Owner

Changes:

  • RedisCache::new now accepts ConnectionManager instead of URL
  • Add manual approval gate (crates-io environment) for publish step
  • Fix release workflow environment name

Summary by CodeRabbit

  • Changes

    • RedisCache can now be initialized with an existing Redis connection manager, enabling connection setup to be handled separately from cache creation.
    • Redis connection initialization is now synchronous when constructing the cache.
  • Documentation

    • Updated the RedisCache example to demonstrate creating and supplying a Redis connection manager.
    • Updated Redis integration examples and validation to use the new initialization approach.
  • Chores

    • Added a protected environment configuration to the package publishing workflow.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

RedisCache now accepts an existing Redis ConnectionManager instead of creating one from a URL. The README and Redis integration tests use the new constructor, and the release workflow assigns publishing to the crates-io environment.

Changes

Redis connection injection

Layer / File(s) Summary
Constructor contract and usage
src/redis.rs, README.md
RedisCache::new now synchronously accepts a ConnectionManager; the README example creates and passes that connection.
Integration test connection setup
tests/redis.rs
Redis tests create connection managers from testcontainer clients and use them in both cache scenarios.

Release environment

Layer / File(s) Summary
Publish environment
.github/workflows/release.yml
The publish job now declares the crates-io environment.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly captures the main changes: a RedisCache API change and a manual publish gate for the release.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release-0.2.0

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kings0x kings0x closed this Jul 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/redis.rs (1)

16-22: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Make redis_conn async
ConnectionManager is tied to the runtime that creates it, so building it inside a throwaway Runtime can abort its driver/reconnect work as soon as redis_conn() returns. Keep it on the test runtime instead:

♻️ Proposed refactor: make redis_conn async
-fn redis_conn() -> ConnectionManager {
+async fn redis_conn() -> ConnectionManager {
     use testcontainers::GenericImage;
     use testcontainers::clients::Cli;

     let client: &'static Cli = Box::leak(Box::new(Cli::default()));
     let image = GenericImage::new("redis", "7-alpine").with_exposed_port(6379);
     let container = client.run(image);
     let port = container.get_host_port_ipv4(6379);
     std::mem::forget(container);
     let url = format!("redis://127.0.0.1:{port}/");
     let client = redis::Client::open(url).expect("invalid redis url");
-    tokio::runtime::Runtime::new()
-        .expect("tokio runtime")
-        .block_on(ConnectionManager::new(client))
-        .expect("connection manager")
+    ConnectionManager::new(client)
+        .await
+        .expect("connection manager")
 }

Then update both call sites in the tests:

-    let conn = redis_conn();
+    let conn = redis_conn().await;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/redis.rs` around lines 16 - 22, Convert redis_conn into an async
function and await ConnectionManager::new directly on the calling test runtime,
removing the temporary tokio::runtime::Runtime creation. Update both redis_conn
call sites in the tests to await the helper while preserving the existing Redis
URL and error handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 90-93: Add a `redis::Client` initialization before
`ConnectionManager::new` in the README example, using the intended Redis
connection configuration, so the existing `ConnectionManager` and
`RedisCache::new` flow compiles when copied.

---

Nitpick comments:
In `@tests/redis.rs`:
- Around line 16-22: Convert redis_conn into an async function and await
ConnectionManager::new directly on the calling test runtime, removing the
temporary tokio::runtime::Runtime creation. Update both redis_conn call sites in
the tests to await the helper while preserving the existing Redis URL and error
handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0e13a325-edad-43cb-be2f-cab89dd7d63e

📥 Commits

Reviewing files that changed from the base of the PR and between 58d0a48 and da8cd1f.

📒 Files selected for processing (4)
  • .github/workflows/release.yml
  • README.md
  • src/redis.rs
  • tests/redis.rs

Comment thread README.md
Comment on lines +90 to +93
use redis::aio::ConnectionManager;

let cache = RedisCache::new("redis://127.0.0.1/").await?;
let conn = ConnectionManager::new(client).await?;
let cache = RedisCache::new(conn);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

README example uses undefined client variable.

The ConnectionManager::new(client) call references client, but no redis::Client is created in the example. Users copying this snippet will hit a compilation error.

📝 Proposed fix to complete the example
 use cacheflight::RedisCache;
 use redis::aio::ConnectionManager;
+use redis::Client;
+
+let client = Client::open("redis://127.0.0.1:6379/")?;

 let conn = ConnectionManager::new(client).await?;
 let cache = RedisCache::new(conn);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use redis::aio::ConnectionManager;
let cache = RedisCache::new("redis://127.0.0.1/").await?;
let conn = ConnectionManager::new(client).await?;
let cache = RedisCache::new(conn);
use cacheflight::RedisCache;
use redis::aio::ConnectionManager;
use redis::Client;
let client = Client::open("redis://127.0.0.1:6379/")?;
let conn = ConnectionManager::new(client).await?;
let cache = RedisCache::new(conn);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 90 - 93, Add a `redis::Client` initialization before
`ConnectionManager::new` in the README example, using the intended Redis
connection configuration, so the existing `ConnectionManager` and
`RedisCache::new` flow compiles when copied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant