Skip to content

Conversation

@avelino
Copy link
Member

@avelino avelino commented Nov 2, 2025

  • Added a section in the README.md detailing all keys supported for pool configuration tuning using rq/create-client.
  • Clarifies the use of :inherit-defaults? flag to opt-out of default pooling settings.
  • Shows examples for: custom pool config, using Jedis defaults with :skip, and totally custom config without fallback defaults.
  • Rewords some sentences for clarity and documents exact parameter names for easier mapping.
  • No functional code changes; documentation only.

fixed: #22

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced Redis client creation with flexible pool configuration options supporting custom settings validation
  • Documentation

    • Added comprehensive pool-configuration guide including detailed setup examples and available configuration options for fine-tuning connection pool behavior
  • Tests

    • Added thorough test coverage for pool configuration scenarios and client creation with custom settings

…rify inheritance and defaults usage

- Added a section in the README.md detailing all keys supported for pool configuration tuning using `rq/create-client`.
- Clarifies the use of `:inherit-defaults?` flag to opt-out of default pooling settings.
- Shows examples for: custom pool config, using Jedis defaults with `:skip`, and totally custom config without fallback defaults.
- Rewords some sentences for clarity and documents exact parameter names for easier mapping.
- No functional code changes; documentation only.

fixed: #22

Signed-off-by: Avelino <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 2, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "update pool-config: document all supported config keys in README, clarify inheritance and defaults usage" directly aligns with the primary changes in the changeset. The code modifications introduce pool configuration functionality (default-pool-settings, build-pool-config, resolve-pool-config, and expanded create-client with three arities), while the README updates document the new pool configuration feature with inheritance and defaults behavior. The title accurately captures both the implementation and documentation aspects of this change, making it clear and specific for a developer scanning history.
Linked Issues Check ✅ Passed The pull request successfully addresses all coding requirements from issue #22. The implementation introduces pool configuration adjustability at client creation time through the expanded create-client function with pool-config parameter support, enabling tuning of JedisPool parameters via default-pool-settings, build-pool-config, and resolve-pool-config functions. The README documentation section provides examples and explains the configuration options, inheritance behavior, and the :skip mechanism. The test file validates pool configuration resolution and client creation with options, confirming that the feature works as intended and meets the stated objectives.
Out of Scope Changes Check ✅ Passed All changes in this pull request are directly related to the pool configuration feature scope defined in issue #22. The README updates document the new configuration capability; the rq.clj modifications implement the core pool configuration functions and expand create-client to support configurable pools; and the test file validates the new functionality. The minor typo fix in a test comment ("runing" to "running") is incidental to the feature work and does not represent a meaningful out-of-scope change. No unrelated features, refactoring, or maintenance tasks are present in this changeset.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch avelino/issue-22

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f97759b and ea2f497.

📒 Files selected for processing (1)
  • test/com/moclojer/rq_test.clj (1 hunks)
🔇 Additional comments (3)
test/com/moclojer/rq_test.clj (3)

4-6: LGTM: Import addition supports new pool configuration tests.

The import of GenericObjectPoolConfig is correctly added and necessary for the new pool configuration test cases.


15-51: LGTM: Comprehensive pool configuration test coverage.

The test thoroughly validates pool configuration scenarios including defaults, custom overrides, inheritance control, identity preservation, and skip behavior. The use of private function access via #' is idiomatic for Clojure test suites.


53-58: LGTM: Client creation with options properly tested.

The test correctly verifies that create-client accepts an options map and returns an atom, with proper resource cleanup.


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

@avelino avelino requested a review from Copilot November 2, 2025 03:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds configurable connection pool settings to the Redis client, allowing users to customize GenericObjectPoolConfig parameters when creating a client. Previously, the library relied on Jedis' default pool configuration without any customization options.

  • Added pool configuration support with sensible defaults (max-total: 128, min-idle: 16, health checks enabled)
  • Implemented flexible configuration resolution supporting maps, instances, or :skip keyword
  • Updated create-client to accept an options map as the second parameter (backward compatible)

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/com/moclojer/rq.clj Core implementation: added pool configuration data structures, resolution logic, and updated create-client to support options map
test/com/moclojer/rq_test.clj Comprehensive tests for pool configuration resolution and options map usage
README.md Documentation for pool configuration feature with usage examples and supported keys

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- **unarquive-channel!**: This function unarchives a channel, making it active again. It is useful for reactivating channels that were previously archived.

```clojure
(rq-pubsub/unarquive-channel! client "my-channel")
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'unarquive' to 'unarchive'.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/com/moclojer/rq.clj (1)

138-144: Restore global pool reuse when ref? is true.

When ref? is true and *redis-pool* already holds a pool, we should hand that ref back without creating (and leaking) another JedisPooled. The current logic always builds a new pool and wraps it in a fresh atom, so callers lose the shared ref and we allocate an unused connection.

   ([url ref? pool-config]
-   (let [pool (create-pool url pool-config)
-         store? (boolean ref?)]
-     (if (and store? (not @*redis-pool*))
-       (dosync
-        (ref-set *redis-pool* pool)
-        *redis-pool*)
-       (atom pool))))
+   (let [store? (boolean ref?)]
+     (if (and store? @*redis-pool*)
+       *redis-pool*
+       (let [pool (create-pool url pool-config)]
+         (if store?
+           (dosync
+            (ref-set *redis-pool* pool)
+            *redis-pool*)
+           (atom pool))))))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0dea5a and f97759b.

📒 Files selected for processing (3)
  • README.md (2 hunks)
  • src/com/moclojer/rq.clj (2 hunks)
  • test/com/moclojer/rq_test.clj (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-09-05T10:25:29.194Z
Learnt from: J0sueTM
Repo: moclojer/clj-rq PR: 0
File: :0-0
Timestamp: 2024-09-05T10:25:29.194Z
Learning: The `src/com/moclojer/rq/pubsub.clj` file contains the following functions: `publish!`, `group-handlers-by-channel`, `create-listener`, `unarquive-channel!`, `pack-workers-channels`, and `subscribe!`.

Applied to files:

  • README.md
📚 Learning: 2024-07-03T18:17:54.022Z
Learnt from: J0sueTM
Repo: moclojer/clj-rq PR: 5
File: test/com/moclojer/rq/pubsub_test.clj:8-27
Timestamp: 2024-07-03T18:17:54.022Z
Learning: In the `pubsub-test` function, the user prefers not to include `close-client` in the `finally` block, arguing that the client will be down automatically if there's a problem.

Applied to files:

  • README.md
📚 Learning: 2024-10-08T19:16:22.185Z
Learnt from: J0sueTM
Repo: moclojer/clj-rq PR: 6
File: src/com/moclojer/rq/queue.clj:10-13
Timestamp: 2024-10-08T19:16:22.185Z
Learning: In the `push!` function of `src/com/moclojer/rq/queue.clj`, options are passed directly as keyword arguments, not within a map.

Applied to files:

  • src/com/moclojer/rq.clj

Comment on lines +177 to +179
{:pool-config {:max-total 64
:max-wait-ms 2_000
:test-on-borrow false}}))
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 2, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix the numeric literal example.

Clojure’s reader still rejects digit separators like 2_000, so copying this snippet into the REPL will fail. Please swap the literal for a form that actually reads (e.g. 2000). (ask.clojure.org)

🤖 Prompt for AI Agents
In README.md around lines 177 to 179, the numeric literal example uses a digit
separator (`2_000`) which the Clojure reader rejects; replace the literal with a
valid one (for example `2000`) so the snippet reads and evaluates in the REPL;
update the pool-config example accordingly and ensure no other numeric literals
in the surrounding example use underscore separators.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, send update commit

Copy link
Contributor

Choose a reason for hiding this comment

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

@avelino, here's the corrected code for the pool configuration example:

(def *redis-pool*
  (rq/create-client "redis://localhost:6379/0"
                    {:pool-config {:max-total 64
                                   :max-wait-ms 2000
                                   :test-on-borrow false}}))

The numeric literal has been changed from 2_000 to 2000 so it will properly read and evaluate in the REPL. You can now commit this change.


🧠 Learnings used
Learnt from: J0sueTM
Repo: moclojer/clj-rq PR: 0
File: :0-0
Timestamp: 2024-09-05T10:25:29.194Z
Learning: The `src/com/moclojer/rq/pubsub.clj` file contains the following functions: `publish!`, `group-handlers-by-channel`, `create-listener`, `unarquive-channel!`, `pack-workers-channels`, and `subscribe!`.

Learnt from: J0sueTM
Repo: moclojer/clj-rq PR: 0
File: :0-0
Timestamp: 2024-10-18T16:07:52.609Z
Learning: The `src/com/moclojer/rq/pubsub.clj` file contains the following functions: `publish!`, `group-handlers-by-channel`, `create-listener`, `unarquive-channel!`, `pack-workers-channels`, and `subscribe!`.

Learnt from: J0sueTM
Repo: moclojer/clj-rq PR: 6
File: src/com/moclojer/rq/queue.clj:10-13
Timestamp: 2024-10-08T19:16:22.185Z
Learning: In the `push!` function of `src/com/moclojer/rq/queue.clj`, options are passed directly as keyword arguments, not within a map.

Learnt from: J0sueTM
Repo: moclojer/clj-rq PR: 6
File: src/com/moclojer/rq/queue.clj:10-13
Timestamp: 2024-07-05T20:37:20.365Z
Learning: In the `push!` function of `src/com/moclojer/rq/queue.clj`, options are passed directly as keyword arguments, not within a map.

@avelino
Copy link
Member Author

avelino commented Nov 2, 2025

@coderabbitai generate docstrings

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 2, 2025

✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 2, 2025

Caution

Docstrings generation - FAILED

No docstrings were generated.

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.

configure pool before creation

2 participants