Skip to content

Implement prioritized push queues#118

Merged
leynos merged 4 commits intomainfrom
codex/implement-prioritized-push-queues
Jun 23, 2025
Merged

Implement prioritized push queues#118
leynos merged 4 commits intomainfrom
codex/implement-prioritized-push-queues

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 23, 2025

Summary

  • add PushHandle and PushQueues for asynchronous message pushes
  • expose new push module publicly
  • test push queue ordering and policy handling
  • document push module purpose and usage

Testing

  • make lint
  • make test

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

Summary by Sourcery

Implement prioritized push queues to enable non-blocking, priority-aware message pushing with backpressure control

New Features:

  • Introduce a push module providing PushQueues and PushHandle for prioritized asynchronous frame dispatch
  • Add support for high- and low-priority message channels with configurable overflow policies (PushPolicy)

Documentation:

  • Document the push module’s purpose and API with mermaid class and flowcharts in the design guide

Tests:

  • Add tests to verify priority ordering, policy enforcement on full queues, and error handling on closed channels

Summary by CodeRabbit

  • New Features
    • Introduced prioritised asynchronous queues for pushing frames, supporting high and low priority levels.
    • Added configurable policies for handling full queues, including error return, silent drop, or warning log.
    • Provided a cloneable handle for producers to asynchronously push frames with chosen priority and policy.
  • Tests
    • Added tests to verify correct priority ordering and policy handling when queues are full.
  • Documentation
    • Enhanced asynchronous outbound messaging design docs with diagrams illustrating API structure and runtime flow.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 23, 2025

Reviewer's Guide

This PR introduces a new push module that provides prioritized, bounded queues for asynchronous frame delivery, exposes it in the public API, enriches the documentation with design diagrams, and adds comprehensive tests covering queue ordering, overflow policies, and closed-queue handling.

Class diagram for the new prioritized push queues module

classDiagram
    class FrameLike {
    }
    class PushPriority {
        <<enum>>
        High
        Low
    }
    class PushPolicy {
        <<enum>>
        ReturnErrorIfFull
        DropIfFull
        WarnAndDropIfFull
    }
    class PushError {
        <<enum>>
        QueueFull
        Closed
    }
    class PushHandleInner {
        high_prio_tx: mpsc::Sender<F>
        low_prio_tx: mpsc::Sender<F>
    }
    class PushHandle {
        +push_high_priority(frame: F): Result<(), PushError>
        +push_low_priority(frame: F): Result<(), PushError>
        +try_push(frame: F, priority: PushPriority, policy: PushPolicy): Result<(), PushError>
    }
    class PushQueues {
        +high_priority_rx: mpsc::Receiver<F>
        +low_priority_rx: mpsc::Receiver<F>
        +bounded(capacity: usize): (PushQueues, PushHandle)
    }

    PushHandleInner <.. PushHandle : contains
    PushQueues o-- PushHandle : bounded()
    PushHandle --> PushPriority
    PushHandle --> PushPolicy
    PushHandle --> PushError
    PushQueues --> PushHandle
    PushQueues --> FrameLike
    PushHandle --> FrameLike
Loading

Flow diagram for prioritized push queue operations and overflow policy handling

flowchart TD
    Producer[Producer]
    PushHandle[PushHandle]
    HighQueue[High Priority Queue]
    LowQueue[Low Priority Queue]
    Policy[PushPolicy]
    Error[PushError or Drop]

    Producer -->|push_high_priority / push_low_priority / try_push| PushHandle
    PushHandle -->|High| HighQueue
    PushHandle -->|Low| LowQueue
    PushHandle -->|If queue full| Policy
    Policy -->|ReturnErrorIfFull| Error
    Policy -->|DropIfFull| Error
    Policy -->|WarnAndDropIfFull| Error
Loading

File-Level Changes

Change Details Files
Introduce prioritized push queue infrastructure
  • Define FrameLike trait and implement it for all Send + 'static types
  • Add PushPriority, PushPolicy, and PushError enums
  • Implement PushHandle with async push_high_priority, push_low_priority, and try_push with policy handling
  • Implement PushQueues.bounded to create paired sender/receiver channels
src/push.rs
Expose new push module publicly
  • Add pub mod push; to the crate root to expose the module
src/lib.rs
Document push module purpose and design
  • Embed Mermaid class and flow diagrams into the asynchronous outbound messaging design doc
  • Add module-level doc comments in push.rs describing queue behavior and APIs
docs/asynchronous-outbound-messaging-design.md
src/push.rs
Add tests for queue behavior and policy enforcement
  • Test that frames are routed to the correct high- and low-priority queues
  • Verify try_push respects overflow policies and returns errors when expected
  • Ensure push methods error out when the receiving end is closed
tests/push.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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 23, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new push module has been introduced and made public in the crate. This module implements prioritised asynchronous queues for frames, supporting high and low priorities, configurable push policies, and error handling. Associated tests have been added to verify priority ordering and push policy behaviour in asynchronous contexts. Documentation has been enhanced with Mermaid diagrams illustrating the API structure and runtime flow.

Changes

File(s) Change Summary
src/lib.rs Added public export for new push module.
src/push.rs Introduced push module: async prioritised queues, PushHandle, PushQueues, priority and policy enums, and errors.
tests/push.rs Added async tests for PushQueues verifying priority routing, push policy enforcement, and error handling on closure.
docs/asynchronous-outbound-... Added Mermaid diagrams illustrating PushHandle API structure and runtime push flow with policies and error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Producer as Producer (PushHandle)
    participant PushQueues as PushQueues
    participant Consumer as Consumer (Receiver)

    Producer->>PushQueues: push_high_priority(frame)
    alt Queue not full
        PushQueues->>Consumer: frame (high priority)
        Producer-->>PushQueues: Ok
    else Queue full
        alt Policy: ReturnErrorIfFull
            Producer-->>PushQueues: Err(QueueFull)
        else Policy: DropIfFull or WarnAndDropIfFull
            PushQueues-->>Producer: Drop frame (optionally log)
        end
    end

    Producer->>PushQueues: push_low_priority(frame)
    alt Queue not full
        PushQueues->>Consumer: frame (low priority)
        Producer-->>PushQueues: Ok
    else Queue full
        alt Policy: ReturnErrorIfFull
            Producer-->>PushQueues: Err(QueueFull)
        else Policy: DropIfFull or WarnAndDropIfFull
            PushQueues-->>Producer: Drop frame (optionally log)
        end
    end
Loading

Poem

In the warren, queues now hop in line,
With high and low, their priorities shine.
Frames leap ahead, or sometimes wait,
Policies decide each frame’s fate.
Async rabbits test, with twitchy delight—
All is in order, from morning till night!
🐇✨

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch codex/implement-prioritized-push-queues

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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

@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 @leynos - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `tests/push.rs:7` </location>
<code_context>
+async fn push_queues_preserve_priority_order() {
+    let (mut queues, handle) = PushQueues::bounded(1);
+
+    handle.push_low_priority(1u8).await.unwrap();
+    handle.push_high_priority(2u8).await.unwrap();
+
+    let high = queues.high_priority_rx.recv().await;
+    let low = queues.low_priority_rx.recv().await;
+
+    assert_eq!(high, Some(2));
+    assert_eq!(low, Some(1));
+}
+
</code_context>

<issue_to_address>
No test for PushError::Closed when receiver is dropped.

Add a test that drops the PushQueues or their receivers, then attempts to push a frame and checks that PushError::Closed is returned. This will improve coverage of error handling for closed queues.

Suggested implementation:

```rust
use wireframe::push::{PushPolicy, PushPriority, PushQueues, PushError};

```

```rust
#[tokio::test]
async fn push_queues_preserve_priority_order() {
    let (mut queues, handle) = PushQueues::bounded(1);

}

#[tokio::test]
async fn push_queues_error_on_closed() {
    let (mut queues, handle) = PushQueues::bounded(1);

    // Drop the high priority receiver
    drop(queues.high_priority_rx);

    // Try to push to high priority queue, should return PushError::Closed
    let res = handle.push_high_priority(42u8).await;
    assert!(matches!(res, Err(PushError::Closed)));

    // Drop the low priority receiver
    drop(queues.low_priority_rx);

    // Try to push to low priority queue, should return PushError::Closed
    let res = handle.push_low_priority(24u8).await;
    assert!(matches!(res, Err(PushError::Closed)));
}

```
</issue_to_address>

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.

Comment thread tests/push.rs Outdated
Comment on lines +7 to +14
handle.push_low_priority(1u8).await.unwrap();
handle.push_high_priority(2u8).await.unwrap();

let high = queues.high_priority_rx.recv().await;
let low = queues.low_priority_rx.recv().await;

assert_eq!(high, Some(2));
assert_eq!(low, Some(1));
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.

suggestion (testing): No test for PushError::Closed when receiver is dropped.

Add a test that drops the PushQueues or their receivers, then attempts to push a frame and checks that PushError::Closed is returned. This will improve coverage of error handling for closed queues.

Suggested implementation:

use wireframe::push::{PushPolicy, PushPriority, PushQueues, PushError};
#[tokio::test]
async fn push_queues_preserve_priority_order() {
    let (mut queues, handle) = PushQueues::bounded(1);

}

#[tokio::test]
async fn push_queues_error_on_closed() {
    let (mut queues, handle) = PushQueues::bounded(1);

    // Drop the high priority receiver
    drop(queues.high_priority_rx);

    // Try to push to high priority queue, should return PushError::Closed
    let res = handle.push_high_priority(42u8).await;
    assert!(matches!(res, Err(PushError::Closed)));

    // Drop the low priority receiver
    drop(queues.low_priority_rx);

    // Try to push to low priority queue, should return PushError::Closed
    let res = handle.push_low_priority(24u8).await;
    assert!(matches!(res, Err(PushError::Closed)));
}

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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cec6175 and 4fb72fa.

📒 Files selected for processing (3)
  • src/lib.rs (1 hunks)
  • src/push.rs (1 hunks)
  • tests/push.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-test
  • GitHub Check: Analyze (actions)
🔇 Additional comments (6)
src/lib.rs (1)

15-15: LGTM! Clean module export.

The addition of the push module follows the established pattern and correctly exposes the new functionality as part of the public API.

tests/push.rs (1)

17-30: Excellent test coverage for push policy behaviour.

This test effectively validates that try_push respects the ReturnErrorIfFull policy and correctly handles queue capacity limits. The test flow is logical and comprehensive.

src/push.rs (4)

17-19: Good use of marker trait pattern.

The FrameLike trait effectively uses the marker trait pattern to document intent whilst providing type safety. The blanket implementation is idiomatic Rust.


21-46: Well-designed enums with comprehensive coverage.

The three enums provide clear, well-documented interfaces:

  • PushPriority covers the essential priority levels
  • PushPolicy addresses common queue-full scenarios comprehensively
  • PushError captures the relevant error conditions

All have appropriate derives and documentation.


48-55: Excellent handle design using Arc for shared ownership.

The PushHandle design correctly uses Arc to enable cloning whilst sharing the underlying channels. This allows multiple producers to push to the same queues efficiently.


122-146: Solid implementation with intentional public field design.

The PushQueues implementation is well-structured:

  • Good use of #[must_use] attribute on bounded()
  • Clean channel creation and tuple return pattern
  • Public receiver fields provide direct access, which appears to be an intentional design choice for flexibility

The implementation correctly creates separate channels for each priority level.

Comment thread tests/push.rs
Comment thread src/push.rs
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 23, 2025

@sourcery-ai review

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 @leynos - I've reviewed your changes - here's some feedback:

  • The log call in WarnAndDropIfFull uses a literal {priority:?} instead of interpolating the variable; switch to log::warn!("push queue full; dropping {:?} priority frame", priority) or equivalent.
  • Consider adding a unified recv() method on PushQueues that automatically yields high‐priority frames before low, so consumers don’t have to manage two receivers manually.
  • It might be useful to allow separate capacities for the high‐ and low‐priority channels rather than a single bound, giving more flexibility over resource allocation per priority.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The log call in `WarnAndDropIfFull` uses a literal `{priority:?}` instead of interpolating the variable; switch to `log::warn!("push queue full; dropping {:?} priority frame", priority)` or equivalent.
- Consider adding a unified `recv()` method on `PushQueues` that automatically yields high‐priority frames before low, so consumers don’t have to manage two receivers manually.
- It might be useful to allow separate capacities for the high‐ and low‐priority channels rather than a single bound, giving more flexibility over resource allocation per priority.

## Individual Comments

### Comment 1
<location> `src/push.rs:131` </location>
<code_context>
+    /// Create a new set of queues with the specified bound and return them along
+    /// with a [`PushHandle`] for producers.
+    #[must_use]
+    pub fn bounded(capacity: usize) -> (Self, PushHandle<F>) {
+        let (high_tx, high_rx) = mpsc::channel(capacity);
+        let (low_tx, low_rx) = mpsc::channel(capacity);
</code_context>

<issue_to_address>
Using the same capacity for both queues may not suit all use cases.

Consider allowing separate capacities for high and low priority queues to increase flexibility.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
    /// Create a new set of queues with the specified bound and return them along
    /// with a [`PushHandle`] for producers.
    #[must_use]
    pub fn bounded(capacity: usize) -> (Self, PushHandle<F>) {
        let (high_tx, high_rx) = mpsc::channel(capacity);
        let (low_tx, low_rx) = mpsc::channel(capacity);
=======
    /// Create a new set of queues with the specified bounds for high and low priority,
    /// and return them along with a [`PushHandle`] for producers.
    ///
    /// # Parameters
    /// - `high_capacity`: The capacity for the high priority queue.
    /// - `low_capacity`: The capacity for the low priority queue.
    #[must_use]
    pub fn bounded(high_capacity: usize, low_capacity: usize) -> (Self, PushHandle<F>) {
        let (high_tx, high_rx) = mpsc::channel(high_capacity);
        let (low_tx, low_rx) = mpsc::channel(low_capacity);
>>>>>>> REPLACE

</suggested_fix>

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.

Comment thread src/push.rs Outdated
Comment on lines +128 to +133
/// Create a new set of queues with the specified bound and return them along
/// with a [`PushHandle`] for producers.
#[must_use]
pub fn bounded(capacity: usize) -> (Self, PushHandle<F>) {
let (high_tx, high_rx) = mpsc::channel(capacity);
let (low_tx, low_rx) = mpsc::channel(capacity);
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.

suggestion: Using the same capacity for both queues may not suit all use cases.

Consider allowing separate capacities for high and low priority queues to increase flexibility.

Suggested change
/// Create a new set of queues with the specified bound and return them along
/// with a [`PushHandle`] for producers.
#[must_use]
pub fn bounded(capacity: usize) -> (Self, PushHandle<F>) {
let (high_tx, high_rx) = mpsc::channel(capacity);
let (low_tx, low_rx) = mpsc::channel(capacity);
/// Create a new set of queues with the specified bounds for high and low priority,
/// and return them along with a [`PushHandle`] for producers.
///
/// # Parameters
/// - `high_capacity`: The capacity for the high priority queue.
/// - `low_capacity`: The capacity for the low priority queue.
#[must_use]
pub fn bounded(high_capacity: usize, low_capacity: usize) -> (Self, PushHandle<F>) {
let (high_tx, high_rx) = mpsc::channel(high_capacity);
let (low_tx, low_rx) = mpsc::channel(low_capacity);

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 23, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 23, 2025

@sourcery-ai review

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 23, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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 @leynos - I've reviewed your changes - here's some feedback:

  • The log::warn! call in try_push uses {priority:?} without passing a named argument, which won’t compile—either switch to log::warn!("... {:?} ...", priority) or supply priority=priority explicitly.
  • Consider adding a convenience method on PushQueues (e.g. next() or recv()) that yields the next frame by priority instead of exposing both receivers and forcing consumers to poll them manually.
  • It could be useful to support different capacities for high- and low-priority queues in bounded so that resource allocation can be tuned independently per priority.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `log::warn!` call in `try_push` uses `{priority:?}` without passing a named argument, which won’t compile—either switch to `log::warn!("... {:?} ...", priority)` or supply `priority=priority` explicitly.
- Consider adding a convenience method on `PushQueues` (e.g. `next()` or `recv()`) that yields the next frame by priority instead of exposing both receivers and forcing consumers to poll them manually.
- It could be useful to support different capacities for high- and low-priority queues in `bounded` so that resource allocation can be tuned independently per priority.

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.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 23, 2025

@coderabbitai review

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 23, 2025

@sourcery-ai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 23, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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 @leynos - I've reviewed your changes - here's some feedback:

  • Fix the log formatting in the WarnAndDropIfFull branch — using {priority:?} without providing a named parameter will fail to compile; use positional formatting or supply priority = priority.
  • Add tests for the DropIfFull and WarnAndDropIfFull policies to verify that silent drops and warning logs occur as intended.
  • Consider adding a higher-level consumer abstraction (e.g. a unified Stream) over the two receivers to simplify pulling frames in priority order rather than exposing raw channels.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Fix the log formatting in the WarnAndDropIfFull branch — using `{priority:?}` without providing a named parameter will fail to compile; use positional formatting or supply `priority = priority`.
- Add tests for the DropIfFull and WarnAndDropIfFull policies to verify that silent drops and warning logs occur as intended.
- Consider adding a higher-level consumer abstraction (e.g. a unified Stream) over the two receivers to simplify pulling frames in priority order rather than exposing raw channels.

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.

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: 2

🔭 Outside diff range comments (1)
docs/asynchronous-outbound-messaging-design.md (1)

120-126: Align closing parenthesis indentation
The closing parenthesis of the try_push signature is not aligned with the pub fn declaration, which can impact readability. Consider indenting the ) to match the start of the pub fn line or moving it onto the same line for consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b26d0c and f20b1fe.

📒 Files selected for processing (1)
  • docs/asynchronous-outbound-messaging-design.md (1 hunks)

Comment on lines +129 to +172
```mermaid
classDiagram
class FrameLike {
}
class PushPriority {
<<enum>>
High
Low
}
class PushPolicy {
<<enum>>
ReturnErrorIfFull
DropIfFull
WarnAndDropIfFull
}
class PushError {
<<enum>>
QueueFull
Closed
}
class PushHandleInner {
high_prio_tx: mpsc::Sender<F>
low_prio_tx: mpsc::Sender<F>
}
class PushHandle {
+push_high_priority(frame: F): Result<(), PushError>
+push_low_priority(frame: F): Result<(), PushError>
+try_push(frame: F, priority: PushPriority, policy: PushPolicy): Result<(), PushError>
}
class PushQueues {
+high_priority_rx: mpsc::Receiver<F>
+low_priority_rx: mpsc::Receiver<F>
+bounded(capacity: usize): (PushQueues, PushHandle)
}

PushHandleInner <.. PushHandle : contains
PushQueues o-- PushHandle : bounded()
PushHandle --> PushPriority
PushHandle --> PushPolicy
PushHandle --> PushError
PushQueues --> PushHandle
PushQueues --> FrameLike
PushHandle --> FrameLike
```
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)

Enhance class diagram accuracy
The mermaid class diagram captures the main types and relationships well. As a refinement, you might:

  • Annotate PushHandle and PushQueues with their generic parameter <F> to mirror the Rust signature.
  • Update the bounded() relationship label to bounded(capacity: usize) so it matches the actual method signature.
    These tweaks will keep the visual model in sync with the code.
🤖 Prompt for AI Agents
In docs/asynchronous-outbound-messaging-design.md between lines 129 and 172,
update the mermaid class diagram to annotate PushHandle and PushQueues with
their generic parameter <F> to reflect the Rust code accurately. Also, modify
the label on the bounded() relationship to bounded(capacity: usize) to match the
actual method signature. These changes will improve the diagram's accuracy and
alignment with the code.

Comment on lines +174 to +190
```mermaid
flowchart TD
Producer[Producer]
PushHandle[PushHandle]
HighQueue[High Priority Queue]
LowQueue[Low Priority Queue]
Policy[PushPolicy]
Error[PushError or Drop]

Producer -->|push_high_priority / push_low_priority / try_push| PushHandle
PushHandle -->|High| HighQueue
PushHandle -->|Low| LowQueue
PushHandle -->|If queue full| Policy
Policy -->|ReturnErrorIfFull| Error
Policy -->|DropIfFull| Error
Policy -->|WarnAndDropIfFull| Error
```
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)

Distinguish blocking vs non-blocking pushes
The flowchart currently conflates push_high_priority / push_low_priority (which await on full queues) with try_push (which applies a policy). For clarity, consider splitting into two branches:

  • One showing the blocking behaviour of the high/low-priority methods.
  • Another illustrating the policy decision tree for try_push.
    This separation will make the push behaviours more explicit.
🤖 Prompt for AI Agents
In docs/asynchronous-outbound-messaging-design.md between lines 174 and 190, the
flowchart mixes blocking push methods (push_high_priority / push_low_priority)
with the non-blocking try_push method that applies a policy. To fix this, split
the flowchart into two branches: one branch showing the blocking behavior of
push_high_priority and push_low_priority leading directly to their respective
queues, and a separate branch illustrating the try_push method leading to the
policy decision tree and possible errors. This will clarify the different push
behaviors.

@leynos leynos merged commit 9c288a9 into main Jun 23, 2025
4 checks passed
@leynos leynos deleted the codex/implement-prioritized-push-queues branch June 23, 2025 19:08
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