Skip to content

Add builder for push queues#335

Open
leynos wants to merge 1 commit intomainfrom
codex/introduce-pushqueuesbuilder-with-deprecation-v0zpc9
Open

Add builder for push queues#335
leynos wants to merge 1 commit intomainfrom
codex/introduce-pushqueuesbuilder-with-deprecation-v0zpc9

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Aug 27, 2025

Summary

  • add PushQueuesBuilder with configuration setters
  • deprecate bounded* constructors and expose PushQueues::builder
  • update tests to use the new builder

Testing

  • make fmt
  • make lint
  • make test

https://chatgpt.com/codex/tasks/task_e_68aeba8d630c8322bcab55de80b2ef06

Summary by Sourcery

Introduce a builder pattern for PushQueues to allow flexible configuration of capacities, rate limiting, and dead-letter queues, deprecate the old constructors in favor of PushQueues::builder, and update tests and docs accordingly.

New Features:

  • Add PushQueuesBuilder with methods for configuring queue capacities, rate limits, and optional dead-letter queue

Enhancements:

  • Deprecate legacy bounded*, bounded_with_rate, and bounded_with_rate_dlq constructors in favor of the new builder
  • Expose PushQueues::builder for fluent queue and handle construction
  • Simplify internal building logic by consolidating constructors into builder implementation

Tests:

  • Update all existing tests and examples to use the new builder API instead of deprecated constructors

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Aug 27, 2025

Reviewer's Guide

This PR refactors PushQueues to use a new builder API: it introduces PushQueuesBuilder with fluent configuration methods, deprecates legacy constructors in favor of the builder, centralizes the queue setup logic into a single internal function, updates all code examples and documentation accordingly, and migrates the test suite to leverage the new builder.

Class diagram for PushQueuesBuilder and PushQueues changes

classDiagram
    class PushQueuesBuilder {
        +high_capacity: usize
        +low_capacity: usize
        +rate: Option<usize>
        +dlq: Option<mpsc::Sender<F>>
        +new() PushQueuesBuilder
        +high_capacity(capacity: usize) PushQueuesBuilder
        +low_capacity(capacity: usize) PushQueuesBuilder
        +rate(rate: Option<usize>) PushQueuesBuilder
        +dlq(dlq: Option<mpsc::Sender<F>>) PushQueuesBuilder
        +build() Result<(PushQueues<F>, PushHandle<F>), PushConfigError>
    }
    class PushQueues {
        +high_priority_rx: mpsc::Receiver<F>
        +low_priority_rx: mpsc::Receiver<F>
        +builder() PushQueuesBuilder<F>
        +close()
        +build_with_rate_dlq(...)
        +bounded(...)
        +bounded_no_rate_limit(...)
        +bounded_with_rate(...)
        +bounded_with_rate_dlq(...)
    }
    PushQueuesBuilder --> PushQueues : builds
Loading

File-Level Changes

Change Details Files
Introduce PushQueuesBuilder and builder API
  • Define PushQueuesBuilder struct with default settings and configuration setters
  • Expose PushQueues::builder() returning a new builder instance
  • Implement build() method to invoke the internal queue construction logic
src/push/queues.rs
src/push/mod.rs
Deprecate legacy constructors in favor of builder
  • Annotate bounded, bounded_no_rate_limit, bounded_with_rate, and bounded_with_rate_dlq with #[deprecated]
  • Refactor these methods to call PushQueues::builder() and delegate to build()
src/push/queues.rs
Centralize and refactor queue construction logic
  • Extract build_with_rate_dlq to handle channel creation, rate limiter setup, and DLQ wiring
  • Validate rate bounds (nonzero and ≤ MAX_PUSH_RATE) in build_with_rate_dlq
  • Update MAX_PUSH_RATE doc comment to reference builder API
src/push/queues.rs
Migrate tests to use the new builder
  • Replace all PushQueues::bounded* and bounded_with_rate* invocations with builder pattern
  • Adjust test fixtures and examples across the test suite to call .builder().high_capacity(...).low_capacity(...).rate(...).build().unwrap()
tests/push.rs
tests/connection_actor.rs
tests/push_policies.rs
tests/stream_end.rs
tests/wireframe_protocol.rs
tests/world.rs
tests/session_registry.rs
tests/advanced/interaction_fuzz.rs
tests/async_stream.rs
tests/correlation_id.rs
tests/advanced/concurrency_loom.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Add a test for the builder’s error path (e.g. builder().rate(Some(0 or > MAX_PUSH_RATE)).build()) so we verify invalid rates are rejected.
  • Enhance the PushQueuesBuilder doc comment with a minimal code example showing default usage (builder().build().unwrap()).
  • Consider deriving Default for PushQueuesBuilder to give users a standard Default::default() entry point alongside builder().
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add a test for the builder’s error path (e.g. builder().rate(Some(0 or > MAX_PUSH_RATE)).build()) so we verify invalid rates are rejected.
- Enhance the PushQueuesBuilder doc comment with a minimal code example showing default usage (builder().build().unwrap()).
- Consider deriving Default for PushQueuesBuilder to give users a standard Default::default() entry point alongside builder().

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 27, 2025

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbit resume to resume automatic reviews.
  • @coderabbit review to trigger a single review.

Summary by CodeRabbit

  • New Features
    • Introduces a builder-based API to configure push queues with separate high/low capacities, optional rate limiting, and an optional dead-letter queue.
  • Refactor
    • Migrates queue initialisation to the new builder pattern for clearer configuration and validation.
    • Deprecates legacy direct constructors in favour of the builder workflow.
  • Documentation
    • Updates examples and guidance to use the builder-based initialisation.
  • Tests
    • Updates test suites to construct queues via the builder and handle build results accordingly.

Walkthrough

Introduce a new push module with a re-exported queues submodule. Add a builder-based API for PushQueues with options for capacities, optional rate limiting, and optional DLQ. Deprecate legacy constructors and route them through the builder. Update tests to construct queues via the builder and unwrap build results.

Changes

Cohort / File(s) Summary of Changes
Module scaffolding
src/push/mod.rs
Add module with doc comment; declare mod queues;; publicly re-export pub use queues::*;.
Push queues builder + internals
src/push/queues.rs
Add PushQueues::builder() and PushQueuesBuilder<F> with high_capacity, low_capacity, rate, dlq, build. Validate rate in builder path; centralise construction in private build_with_rate_dlq(...). Deprecate legacy constructors and delegate to builder. Update docs/examples accordingly.
Advanced tests migration
tests/advanced/*
Replace PushQueues::bounded(...) with builder: .high_capacity(...).low_capacity(...).build().unwrap(). Maintain semantics; adjust to Result-returning build. Files: tests/advanced/concurrency_loom.rs, tests/advanced/interaction_fuzz.rs.
Core behaviour tests migration
tests/push.rs, tests/push_policies.rs
Migrate to builder across tests; configure capacities, optional rate(...), optional dlq(...); use .build().unwrap() or .expect(...). Legacy constructor usages removed in tests.
Async and protocol tests migration
tests/async_stream.rs, tests/wireframe_protocol.rs
Switch to builder-based initialisation; unwrap build result; keep test logic unchanged.
Actor and registry tests migration
tests/connection_actor.rs, tests/session_registry.rs
Update fixtures and in-test setup to builder pattern with same capacities; unwrap build result.
Correlation/stream/world tests migration
tests/correlation_id.rs, tests/stream_end.rs, tests/world.rs
Replace direct constructors with builder-based creation in multiple setups; semantics unchanged aside from Result unwrap.

Sequence Diagram(s)

sequenceDiagram
  participant T as Test/Caller
  participant B as PushQueuesBuilder
  participant PQ as PushQueues
  participant PH as PushHandle
  participant RL as RateLimiter (optional)
  participant DLQ as DLQ Sender (optional)

  T->>PQ: PushQueues::builder()
  activate B
  T->>B: high_capacity(h)\nlow_capacity(l)\nrate(r?)\ndlq(dlq?)
  T->>B: build()
  alt r is Some
    B->>RL: create with rate r
  else r is None
    Note over B,RL: No rate limiter
  end
  alt dlq is Some
    B->>DLQ: attach DLQ
  else
    Note over B,DLQ: No DLQ
  end
  B->>PQ: construct queues (high/low)
  B->>PH: create push handle
  B-->>T: (PushQueues, PushHandle) or Error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

Queues now gather by builder’s light,
High and low set snugly right.
Rates that pace, DLQs that catch,
Tests all dance to a brand-new batch.
Deprecated paths softly fade—
A tidier route is now well-laid.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/introduce-pushqueuesbuilder-with-deprecation-v0zpc9

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
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: 27

Caution

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

⚠️ Outside diff range comments (5)
tests/session_registry.rs (2)

9-12: Replace forbidden #[allow] with narrowly scoped #[expect] including reason

Follow lint policy: forbid #[allow], prefer #[expect(..., reason = "...")].

Apply:

-#[allow(
-    unused_braces,
-    reason = "rustc false positive for single line rstest fixtures"
-)]
+#[expect(
+    unused_braces,
+    reason = "rustc false positive for single-line rstest fixtures"
+)]

16-19: Replace forbidden #[allow] with #[expect] on second fixture

Keep policy consistent.

Apply:

-#[allow(
-    unused_braces,
-    reason = "rustc false positive for single line rstest fixtures"
-)]
+#[expect(
+    unused_braces,
+    reason = "rustc false positive for single-line rstest fixtures"
+)]
tests/push.rs (2)

33-35: Fix docstring: variant is QueueFull, not Full.

Keep docs accurate to the public API.

-/// return `PushError::Full` once the queue is at capacity.
+/// return `PushError::QueueFull` once the queue is at capacity.

1-210: Remove all remaining unwrap calls in src/ and tests/

Found 46 unwrap occurrences across 20 files. Address each as follows:

• src/push/queues.rs (14 calls)
• src/extractor.rs (5 calls)
• tests/push.rs (4 calls)
• tests/connection_actor.rs (3 calls)
• src/server/config/binding.rs (3 calls)
• tests/world.rs (2 calls)
• tests/wireframe_protocol.rs (2 calls)
• tests/stream_end.rs (2 calls)
• tests/session_registry.rs (1 call)
• tests/server.rs (1 call)
• tests/push_policies.rs (1 call)
• tests/correlation_id.rs (1 call)
• tests/async_stream.rs (1 call)
• tests/advanced/interaction_fuzz.rs (1 call)
• tests/advanced/concurrency_loom.rs (1 call)
• src/server/connection.rs (1 call)
• src/frame/tests.rs (1 call)
• src/app.rs (1 call)

Replace production‐code unwrap uses with proper error propagation (e.g. ?, map_err, or expect with descriptive message). In tests, use expect("descriptive failure message") instead of raw unwrap.

Review each file and refactor accordingly.

src/push/queues.rs (1)

53-91: Optionally derive errors via thiserror for cleaner impls.

Reduce boilerplate and standardise error formatting.

+use thiserror::Error;
@@
-#[derive(Debug)]
-pub enum PushError {
+#[derive(Debug, Error)]
+pub enum PushError {
-    QueueFull,
+    #[error("push queue full")]
+    QueueFull,
-    Closed,
+    #[error("push queue closed")]
+    Closed,
 }
@@
-#[derive(Debug)]
-pub enum PushConfigError {
+#[derive(Debug, Error)]
+pub enum PushConfigError {
-    InvalidRate(usize),
+    #[error("invalid rate {0}; must be between 1 and {MAX_PUSH_RATE}")]
+    InvalidRate(usize),
+    #[error("invalid capacities; high={high}, low={low}; each must be ≥ 1")]
+    InvalidCapacity { high: usize, low: usize },
 }
-
-impl std::fmt::Display for PushError { /* remove manual impl */ }
-impl std::fmt::Display for PushConfigError { /* remove manual impl */ }
-
-impl std::error::Error for PushError {}
-impl std::error::Error for PushConfigError {}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 49b2adb and ae58902.

📒 Files selected for processing (13)
  • src/push/mod.rs (1 hunks)
  • src/push/queues.rs (8 hunks)
  • tests/advanced/concurrency_loom.rs (1 hunks)
  • tests/advanced/interaction_fuzz.rs (1 hunks)
  • tests/async_stream.rs (1 hunks)
  • tests/connection_actor.rs (3 hunks)
  • tests/correlation_id.rs (1 hunks)
  • tests/push.rs (8 hunks)
  • tests/push_policies.rs (3 hunks)
  • tests/session_registry.rs (1 hunks)
  • tests/stream_end.rs (2 hunks)
  • tests/wireframe_protocol.rs (2 hunks)
  • tests/world.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Use precise names; boolean names should start with is/has/should
Use en-GB-oxendict spelling and grammar in comments
Function documentation must include clear examples; test documentation should omit redundant examples
Keep code files ≤ 400 lines; split long switch/dispatch logic by feature; move large test data to external files
Disallow Clippy warnings
Fix warnings emitted during tests in code rather than silencing them
Extract helper functions for long functions; adhere to separation of concerns and CQRS
Group related parameters into meaningful structs when functions have many parameters
Consider using Arc for large error returns to reduce data size
Each Rust module must begin with a module-level //! comment describing purpose and utility
Document public APIs with Rustdoc /// comments to enable cargo doc generation
Prefer immutable data; avoid unnecessary mut
Handle errors with Result instead of panicking where feasible
Avoid unsafe code unless necessary and document any usage clearly
Place function attributes after doc comments
Do not use return in single-line functions
Use predicate functions for conditional criteria with more than two branches
Do not silence lints except as a last resort
Lint suppressions must be tightly scoped and include a clear reason
Prefer #[expect(..)] over #[allow(..)] for lints
Prefer .expect() over .unwrap()
Use concat!() to combine long string literals rather than escaping newlines
Prefer single-line function bodies where appropriate (e.g., pub fn new(id: u64) -> Self { Self(id) })
Prefer semantic error enums deriving std::error::Error via thiserror for inspectable conditions

Files:

  • tests/session_registry.rs
  • src/push/mod.rs
  • tests/correlation_id.rs
  • tests/advanced/concurrency_loom.rs
  • tests/advanced/interaction_fuzz.rs
  • tests/async_stream.rs
  • tests/stream_end.rs
  • tests/world.rs
  • tests/connection_actor.rs
  • tests/wireframe_protocol.rs
  • tests/push_policies.rs
  • src/push/queues.rs
  • tests/push.rs

⚙️ CodeRabbit configuration file

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Where code is only used by specific features, it must be conditionally compiled or a conditional expectation for unused_code applied.

  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
  • Environment access (env::set_var and env::remove_var) are always unsafe in Rust 2024 and MUST be marked as such

    • For testing of functionality depending upon environment variables, dependency injection and the mockable crate are the preferred option.
    • If mockable cannot be used, env mutations in tests ...

Files:

  • tests/session_registry.rs
  • src/push/mod.rs
  • tests/correlation_id.rs
  • tests/advanced/concurrency_loom.rs
  • tests/advanced/interaction_fuzz.rs
  • tests/async_stream.rs
  • tests/stream_end.rs
  • tests/world.rs
  • tests/connection_actor.rs
  • tests/wireframe_protocol.rs
  • tests/push_policies.rs
  • src/push/queues.rs
  • tests/push.rs
{src,tests}/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Write unit and behavioural tests for new functionality

Files:

  • tests/session_registry.rs
  • src/push/mod.rs
  • tests/correlation_id.rs
  • tests/advanced/concurrency_loom.rs
  • tests/advanced/interaction_fuzz.rs
  • tests/async_stream.rs
  • tests/stream_end.rs
  • tests/world.rs
  • tests/connection_actor.rs
  • tests/wireframe_protocol.rs
  • tests/push_policies.rs
  • src/push/queues.rs
  • tests/push.rs
tests/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.rs: Use rstest fixtures for shared setup
Replace duplicated tests with #[rstest(...)] parameterised cases
Prefer mockall for mocks/stubs

Files:

  • tests/session_registry.rs
  • tests/correlation_id.rs
  • tests/advanced/concurrency_loom.rs
  • tests/advanced/interaction_fuzz.rs
  • tests/async_stream.rs
  • tests/stream_end.rs
  • tests/world.rs
  • tests/connection_actor.rs
  • tests/wireframe_protocol.rs
  • tests/push_policies.rs
  • tests/push.rs
🧬 Code graph analysis (12)
tests/session_registry.rs (1)
src/push/queues.rs (1)
  • builder (359-359)
src/push/mod.rs (1)
tests/connection_actor.rs (1)
  • queues (25-31)
tests/correlation_id.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
tests/advanced/concurrency_loom.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
tests/advanced/interaction_fuzz.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
tests/async_stream.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
tests/stream_end.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
tests/world.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
tests/connection_actor.rs (1)
src/push/queues.rs (1)
  • builder (359-359)
tests/wireframe_protocol.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
tests/push_policies.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
tests/push.rs (2)
tests/connection_actor.rs (1)
  • queues (25-31)
src/push/queues.rs (1)
  • builder (359-359)
🔇 Additional comments (5)
src/push/mod.rs (1)

3-5: Verify wildcard re-export lint and public module exposure in push::queues

  • File: src/push/mod.rs (lines 3–5)
  • Verified no remaining usages of deprecated PushQueues::bounded* constructors.
  • Decide whether to expose the queues module itself by changing mod queues; to pub mod queues;.

Apply this optional refactor:

-mod queues;
+pub mod queues;

-pub use queues::*;
+// If Clippy flags wildcard imports, re-export specific items instead (preferred).
+// e.g.:
+//     pub use queues::{PushQueues, PushQueuesBuilder, PushHandle};
+pub use queues::*;
  • Verify whether Clippy currently warns on pub use queues::*; under the wildcard_imports lint in your stable toolchain.
  • Confirm that exposing push::queues aligns with your public API and doesn’t introduce unintended breakage.
tests/push_policies.rs (2)

83-89: LGTM: Builder usage with explicit rate/DLQ and expect is consistent.


147-153: LGTM: Builder initialisation and explicit expect message read well.

tests/push.rs (1)

81-87: LGTM: Builder with rate(Some/None) and explicit expect messages.

Also applies to: 119-125, 140-146, 186-192

src/push/queues.rs (1)

293-355: LGTM: Builder API design and defaults mirror the legacy constructors cleanly.

Chaining, defaults, and Result-returning build are idiomatic.

Comment thread src/push/mod.rs
@@ -0,0 +1,5 @@
//! Prioritised queues used for asynchronously pushing frames to a connection.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Elevate module docs with an example and deprecation note

Document the builder-centric API here with a short example and call out deprecated constructors to meet the public API documentation guideline.

Apply:

-//! Prioritised queues used for asynchronously pushing frames to a connection.
+//! Prioritised queues used for asynchronously pushing frames to a connection.
+//!
+//! Example
+//! -------
+//! Build queues and a handle using the builder:
+//!
+//! ```ignore
+//! use wireframe::push::PushQueues;
+//!
+//! let (queues, handle) = PushQueues::<u8>::builder()
+//!     .high_capacity(8)
+//!     .low_capacity(8)
+//!     .build()
+//!     .expect("failed to build push queues");
+//! ```
+//!
+//! Note: legacy `bounded*` constructors are deprecated; use `PushQueues::builder()` instead.
🤖 Prompt for AI Agents
In src/push/mod.rs around lines 1 to 1, augment the module-level documentation
to include a short builder-centric example and a deprecation note: add a doc
example showing how to construct PushQueues using PushQueues::<T>::builder()
with high_capacity, low_capacity and build() (including expect), and append a
single-line note that legacy bounded* constructors are deprecated and users
should use PushQueues::builder() instead; ensure the example is fenced as a Rust
doc test and the deprecation note is concise and placed in the module docs.

Comment thread src/push/queues.rs
Comment on lines +1 to 8
//! Queue management used by [`PushHandle`] and [`PushQueues`].
//!
//! `PushQueues` maintain separate high- and low-priority channels so
//! background tasks can send messages without blocking the request/response
//! cycle. Producers interact with these queues through a cloneable
//! [`PushHandle`]. Queued frames are delivered in FIFO order within each
//! priority level. An optional rate limiter caps throughput at
//! [`MAX_PUSH_RATE`] pushes per second.
//! Provides the core implementation for prioritised queues delivering frames
//! to a connection. Background tasks can send messages without blocking the
//! request/response cycle. Frames maintain FIFO order within each priority
//! level. An optional rate limiter caps throughput at [`MAX_PUSH_RATE`] pushes
//! per second.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Split this module; file length exceeds the 400-line guideline.

Extract builder + errors into submodules (e.g., push/queues/{builder.rs, errors.rs, handle.rs}) and re-export from mod.rs.

Comment thread src/push/queues.rs
Comment on lines +147 to 153
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(Some(1))
/// .build()
/// .unwrap();
/// handle.push_high_priority(42u8).await.unwrap();
/// let (priority, frame) = queues.recv().await.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Use expect in doctest.

Avoid unwrap in examples per house style.

-    ///         .build()
-    ///         .unwrap();
+    ///         .build()
+    ///         .expect("failed to build queues");
📝 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
/// let (mut queues, handle) = PushQueues::builder()
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(Some(1))
/// .build()
/// .unwrap();
/// handle.push_high_priority(42u8).await.unwrap();
/// let (mut queues, handle) = PushQueues::builder()
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(Some(1))
/// .build()
/// .expect("failed to build queues");
/// handle.push_high_priority(42u8).await.unwrap();
🤖 Prompt for AI Agents
In src/push/queues.rs around lines 147 to 153, the doctest uses unwrap() which
violates house style; replace unwrap() calls with expect(...) that include
brief, clear failure messages (e.g., "failed to build PushQueues" and "failed to
push_high_priority") so the example still panics with useful context while
avoiding unwrap().

Comment thread src/push/queues.rs
Comment on lines +178 to 184
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(Some(1))
/// .build()
/// .unwrap();
/// handle.push_low_priority(10u8).await.unwrap();
/// let (priority, frame) = queues.recv().await.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Use expect in doctest.

-    ///         .build()
-    ///         .unwrap();
+    ///         .build()
+    ///         .expect("failed to build queues");
📝 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
/// let (mut queues, handle) = PushQueues::builder()
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(Some(1))
/// .build()
/// .unwrap();
/// handle.push_low_priority(10u8).await.unwrap();
/// let (mut queues, handle) = PushQueues::builder()
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(Some(1))
/// .build()
/// .expect("failed to build queues");
/// handle.push_low_priority(10u8).await.unwrap();
🤖 Prompt for AI Agents
In src/push/queues.rs around lines 178 to 184, the doctest uses unwrap() which
is discouraged; replace unwrap() calls with expect(...) that include clear
messages (e.g., .build().expect("failed to build PushQueues") and
.await.expect("push_low_priority failed")) so test failures give helpful
context; update both unwraps in the snippet accordingly.

Comment thread src/push/queues.rs
Comment on lines +231 to 237
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(None)
/// .dlq(Some(dlq_tx))
/// .build()
/// .unwrap();
/// handle.push_high_priority(1u8).await.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Use expect in doctest.

-    ///         .build()
-    ///         .unwrap();
+    ///         .build()
+    ///         .expect("failed to build queues");
📝 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
/// let (mut queues, handle) = PushQueues::builder()
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(None)
/// .dlq(Some(dlq_tx))
/// .build()
/// .unwrap();
/// let (mut queues, handle) = PushQueues::builder()
/// .high_capacity(1)
/// .low_capacity(1)
/// .rate(None)
/// .dlq(Some(dlq_tx))
/// .build()
/// .expect("failed to build queues");
🤖 Prompt for AI Agents
In src/push/queues.rs around lines 231 to 237, the doctest currently ends with
.build().unwrap(); — replace the unwrap() with expect(...) to provide a clear
failure message in tests; update the line to use .build().expect("failed to
build PushQueues in doctest") so the doctest fails with a helpful message
instead of panicking without context.

Comment thread tests/stream_end.rs
Comment on lines +58 to +62
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

🛠️ Refactor suggestion

Repeat: replace unwrap() and make type explicit

Mirror the safer, consistent pattern here too.

-    let (queues, handle) = PushQueues::builder()
+    let (queues, handle) = PushQueues::<u8>::builder()
         .high_capacity(1)
         .low_capacity(1)
         .build()
-        .unwrap();
+        .expect("failed to build push queues");
📝 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
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.unwrap();
let (queues, handle) = PushQueues::<u8>::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.expect("failed to build push queues");
🤖 Prompt for AI Agents
In tests/stream_end.rs around lines 58 to 62, replace the .unwrap() call on
.build() with explicit error handling (either propagate the Result with ? from
the test function or call expect("...") with a clear message) and declare the
tuple's type explicitly (e.g. let (queues, handle): (PushQueues<...>, ... ) =
...) so the types are clear and unwrap() is removed.

Comment on lines +59 to +63
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace .unwrap() with .expect(...) for builder

Meet the .expect() preference and provide actionable error context.

Apply:

-    let (queues, handle) = PushQueues::builder()
+    let (queues, handle) = PushQueues::builder()
         .high_capacity(1)
         .low_capacity(1)
-        .build()
-        .unwrap();
+        .build()
+        .expect("failed to build push queues for protocol hooks test")
📝 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
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.unwrap();
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.expect("failed to build push queues for protocol hooks test");
🤖 Prompt for AI Agents
In tests/wireframe_protocol.rs around lines 59 to 63, the PushQueues builder
call uses .unwrap(), replace it with .expect(...) to provide actionable error
context; change the call to .expect("failed to build PushQueues with
high_capacity=1 low_capacity=1") (or similar descriptive message) so test
failures show why the builder panicked.

Comment on lines +87 to +91
let (queues, handle) = PushQueues::builder()
.high_capacity(8)
.low_capacity(8)
.build()
.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace .unwrap() with .expect(...) for builder (second occurrence)

Keep tests consistent with lint policy.

Apply:

-    let (queues, handle) = PushQueues::builder()
+    let (queues, handle) = PushQueues::builder()
         .high_capacity(8)
         .low_capacity(8)
-        .build()
-        .unwrap();
+        .build()
+        .expect("failed to build push queues for connection_actor protocol test")
📝 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
let (queues, handle) = PushQueues::builder()
.high_capacity(8)
.low_capacity(8)
.build()
.unwrap();
let (queues, handle) = PushQueues::builder()
.high_capacity(8)
.low_capacity(8)
.build()
.expect("failed to build push queues for connection_actor protocol test");
🤖 Prompt for AI Agents
In tests/wireframe_protocol.rs around lines 87 to 91, replace the second
.unwrap() call on
PushQueues::builder().high_capacity(8).low_capacity(8).build().unwrap() with
.expect(...) to follow the lint policy; change it to .expect("failed to build
PushQueues in test") (or a similar concise message) so the test panics with a
clear error message instead of using unwrap().

Comment thread tests/world.rs
Comment on lines +145 to +149
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

🛠️ Refactor suggestion

Use expect() and explicit generic (Envelope) for the builder

Conform to lint policy and clarify the frame type at construction.

-        let (queues, handle) = PushQueues::builder()
+        let (queues, handle) = PushQueues::<Envelope>::builder()
             .high_capacity(1)
             .low_capacity(1)
             .build()
-            .unwrap();
+            .expect("failed to build push queues");
📝 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
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.unwrap();
let (queues, handle) = PushQueues::<Envelope>::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.expect("failed to build push queues");
🤖 Prompt for AI Agents
In tests/world.rs around lines 145 to 149, the PushQueues builder call uses
unwrap() and omits the explicit frame type; change PushQueues::builder() to
specify the Envelope generic (e.g. PushQueues::<Envelope>::builder()) and
replace .unwrap() with .expect("failed to build PushQueues") (or a similar
descriptive message) so the code conforms to lint policy and clarifies the frame
type at construction.

Comment thread tests/world.rs
Comment on lines +187 to +191
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

🛠️ Refactor suggestion

Apply the same fix: expect() over unwrap() and explicit u8

Keep the tests consistent and lint-clean.

-        let (queues, handle) = PushQueues::builder()
+        let (queues, handle) = PushQueues::<u8>::builder()
             .high_capacity(1)
             .low_capacity(1)
             .build()
-            .unwrap();
+            .expect("failed to build push queues");
📝 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
let (queues, handle) = PushQueues::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.unwrap();
let (queues, handle) = PushQueues::<u8>::builder()
.high_capacity(1)
.low_capacity(1)
.build()
.expect("failed to build push queues");
🤖 Prompt for AI Agents
In tests/world.rs around lines 187 to 191, replace the use of .unwrap() on the
PushQueues::builder() result with .expect(...) and make the capacity literals
explicitly u8 (e.g. 1u8) so the test is lint-clean and consistent; update the
call to .build().expect("failed to build PushQueues") and change
.high_capacity(1) and .low_capacity(1) to .high_capacity(1u8) and
.low_capacity(1u8).

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 29, 2025

@coderabbitai please create a new GitHub issue for the following:

1-210: Remove all remaining unwrap calls in src/ and tests/

Found 46 unwrap occurrences across 20 files. Address each as follows:

• src/push/queues.rs (14 calls)
• src/extractor.rs (5 calls)
• tests/push.rs (4 calls)
• tests/connection_actor.rs (3 calls)
• src/server/config/binding.rs (3 calls)
• tests/world.rs (2 calls)
• tests/wireframe_protocol.rs (2 calls)
• tests/stream_end.rs (2 calls)
• tests/session_registry.rs (1 call)
• tests/server.rs (1 call)
• tests/push_policies.rs (1 call)
• tests/correlation_id.rs (1 call)
• tests/async_stream.rs (1 call)
• tests/advanced/interaction_fuzz.rs (1 call)
• tests/advanced/concurrency_loom.rs (1 call)
• src/server/connection.rs (1 call)
• src/frame/tests.rs (1 call)
• src/app.rs (1 call)

Replace production‐code unwrap uses with proper error propagation (e.g. ?, map_err, or expect with descriptive message). In tests, use expect("descriptive failure message") instead of raw unwrap.

Review each file and refactor accordingly.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 29, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

I'll create a GitHub issue for removing the unwrap calls across the codebase.

@leynos I've created a GitHub issue to track the removal of unwrap calls across the codebase. The issue includes the detailed breakdown of files and occurrence counts you provided, along with the specific guidance for handling production code versus test code differently.


🏁 Script executed:

#!/bin/bash
# Create GitHub issue for removing unwrap calls
gh issue create \
  --title "Remove all remaining unwrap calls in src/ and tests/" \
  --body "## Summary

Found 46 unwrap occurrences across 20 files that need to be addressed for better error handling.

## Files and Occurrence Count

• src/push/queues.rs (14 calls)
• src/extractor.rs (5 calls)
• tests/push.rs (4 calls)
• tests/connection_actor.rs (3 calls)
• src/server/config/binding.rs (3 calls)
• tests/world.rs (2 calls)
• tests/wireframe_protocol.rs (2 calls)
• tests/stream_end.rs (2 calls)
• tests/session_registry.rs (1 call)
• tests/server.rs (1 call)
• tests/push_policies.rs (1 call)
• tests/correlation_id.rs (1 call)
• tests/async_stream.rs (1 call)
• tests/advanced/interaction_fuzz.rs (1 call)
• tests/advanced/concurrency_loom.rs (1 call)
• src/server/connection.rs (1 call)
• src/frame/tests.rs (1 call)
• src/app.rs (1 call)

## Requirements

**Production Code (src/)**
Replace unwrap uses with proper error propagation:
- Use \`?\` operator where appropriate
- Use \`map_err\` for error transformation
- Use \`expect\` with descriptive messages where unwrap is unavoidable

**Test Code (tests/)**
Replace raw \`unwrap()\` calls with \`expect(\"descriptive failure message\")\` to provide better debugging information when tests fail.

## Task

Review each file and refactor accordingly to improve error handling and debugging experience.

## References

- Related PR: https://github.com/leynos/wireframe/pull/335
- Original request: https://github.com/leynos/wireframe/pull/335#discussion_r1735116789" \
  --assignee leynos

Length of output: 1571


Perfect! I've successfully created GitHub issue #337 for removing the unwrap calls across the codebase. The issue has been assigned to you and includes:

  • Complete breakdown of all 46 unwrap occurrences across 20 files
  • Clear requirements for production vs test code handling
  • Proper references back to this PR and comment thread

You can track the progress at: #337

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 29, 2025

@coderabbitai pause

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 29, 2025

✅ Actions performed

Reviews paused.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 29, 2025

@coderabbitai Have the following now been resolved?

  • Add a test for the builder’s error path (e.g. builder().rate(Some(0 or > MAX_PUSH_RATE)).build()) so we verify invalid rates are rejected.
  • Enhance the PushQueuesBuilder doc comment with a minimal code example showing default usage (builder().build().unwrap()).
  • Consider deriving Default for PushQueuesBuilder to give users a standard Default::default() entry point alongside builder().

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 29, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@leynos Let me check the current state of the code to see if those items have been addressed.

Based on my examination of the codebase, here's the status of the three items:

❌ Not Resolved:

  1. Add a test for the builder's error path - I don't see any tests that specifically verify invalid rate rejection (e.g., rate(Some(0)) or rate(Some(value > MAX_PUSH_RATE))). The tests are using valid rates or None.

  2. Enhance PushQueuesBuilder doc comment with example - The PushQueuesBuilder struct appears to lack comprehensive documentation with usage examples.

  3. Consider deriving Default for PushQueuesBuilder - The struct doesn't derive Default trait.

All three items remain unaddressed in the current PR. Add tests for error conditions, improve documentation with examples, and consider adding Default derivation for better ergonomics.


🏁 Script executed:

#!/bin/bash
# Check for error path tests in test files
echo "=== Checking for builder error path tests ==="
rg -n -A5 -B2 "rate.*0|MAX_PUSH_RATE|PushConfigError|InvalidRate" tests/

# Check PushQueuesBuilder documentation
echo -e "\n=== Checking PushQueuesBuilder doc comment ==="
rg -n -A10 -B2 "PushQueuesBuilder" src/push/queues.rs | head -20

# Check if PushQueuesBuilder derives Default
echo -e "\n=== Checking for Default derivation on PushQueuesBuilder ==="
rg -n -A3 -B3 "#\[derive.*Default\]|struct PushQueuesBuilder" src/push/queues.rs

# Look for any builder error tests more broadly
echo -e "\n=== Searching for any builder build() error tests ==="
rg -n -A5 -B2 "build\(\).*expect|build\(\).*unwrap|build\(\).*Err" tests/

Length of output: 2506


🏁 Script executed:

#!/bin/bash
# Get the full PushQueuesBuilder struct definition and its documentation
echo "=== Full PushQueuesBuilder definition ==="
ast-grep --pattern 'struct PushQueuesBuilder$_$ {
  $$$
}'

# Look for specific error tests related to rate validation
echo -e "\n=== Checking for rate validation tests ==="
rg -n -A10 -B5 "rate.*Some.*0|rate.*Some.*[0-9]+.*build|InvalidRate|PushConfigError" tests/ --type rust

# Check the constants and validation logic
echo -e "\n=== Checking MAX_PUSH_RATE and validation ==="
rg -n -A5 -B2 "MAX_PUSH_RATE|InvalidRate" src/push/queues.rs

Length of output: 3500


🏁 Script executed:

#!/bin/bash
# Look at the actual PushQueuesBuilder implementation to see documentation
echo "=== PushQueuesBuilder documentation and implementation ==="
sed -n '/pub struct PushQueuesBuilder/,/^}/p' src/push/queues.rs

# Check if there are any #[derive] attributes before PushQueuesBuilder
echo -e "\n=== Checking derive attributes ==="
rg -n -A1 -B3 "pub struct PushQueuesBuilder" src/push/queues.rs

# Look for any error path tests more specifically
echo -e "\n=== Looking for specific test functions that might test error paths ==="
rg -n -A10 "fn.*test.*error|fn.*test.*invalid|fn.*test.*rate" tests/ --type rust

Length of output: 996


@leynos Based on my examination of the current codebase, here's the status of the three items:

❌ All three items remain unresolved:

  1. Add a test for the builder's error path - No tests exist that verify invalid rate rejection (e.g., rate(Some(0)) or rates exceeding MAX_PUSH_RATE). All current tests use valid parameters.

  2. Enhance PushQueuesBuilder doc comment with example - The PushQueuesBuilder struct has minimal documentation without usage examples. The current docs only mention defaults but lack a practical example.

  3. Consider deriving Default for PushQueuesBuilder - The struct doesn't derive Default. Currently defined as:

    pub struct PushQueuesBuilder<F> {
        high_capacity: usize,
        low_capacity: usize,
        rate: Option<usize>,
        dlq: Option<mpsc::Sender<F>>,
    }

The validation logic exists (rates are checked against MAX_PUSH_RATE and zero), but no tests verify these error paths are working correctly.


🏁 Script executed:

#!/bin/bash
# Get the complete documentation for PushQueuesBuilder
echo "=== Complete PushQueuesBuilder documentation ==="
sed -n '/^\/\/\/ Builder for/,/^pub struct PushQueuesBuilder/p' src/push/queues.rs

# Check if there are tests that specifically test error conditions
echo -e "\n=== Checking for error-related test functions ==="
rg -n "fn test_|#\[test\]" tests/push.rs -A5 | grep -E "(error|invalid|rate|build)"

# Look for any tests that call .build() and check for errors
echo -e "\n=== Looking for tests that handle build() errors ==="
rg -n -A10 -B5 "build\(\)" tests/push.rs | grep -E "(Err|expect|unwrap|Result)"

Length of output: 2591


@leynos Based on my thorough examination of the codebase, none of the three items have been resolved yet:

Unresolved Items:

  1. Missing error path tests - No tests exist that verify invalid rate rejection. The validation logic exists in build_with_rate_dlq() but isn't tested:

    if let Some(r) = rate.filter(|r| *r == 0 || *r > MAX_PUSH_RATE) {
        return Err(PushConfigError::InvalidRate(r));
    }
  2. Minimal documentation - PushQueuesBuilder has basic docs but lacks usage examples:

    /// Builder for [`PushQueues`].
    ///
    /// Allows configuration of queue capacities, rate limiting and an optional
    /// dead-letter queue before constructing [`PushQueues`] and its paired
    /// [`PushHandle`]. Defaults mirror the previous constructors: both queues have
    /// a capacity of one and pushes are limited to [`DEFAULT_PUSH_RATE`] per second
    /// unless overridden.
    
  3. No Default derivation - The struct doesn't implement Default:

    pub struct PushQueuesBuilder<F> {
        high_capacity: usize,
        low_capacity: usize,
        rate: Option<usize>,
        dlq: Option<mpsc::Sender<F>>,
    }

All three items still need to be addressed before this PR is complete.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant