Skip to content

Document server-initiated packet design#122

Merged
leynos merged 8 commits intomainfrom
codex/refactor-connection-write-loop
Jun 24, 2025
Merged

Document server-initiated packet design#122
leynos merged 8 commits intomainfrom
codex/refactor-connection-write-loop

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 24, 2025

Summary

  • clarify stateful connection actors and their transition from per-request workers
  • add WebSocket and MQTT examples in the push design
  • mention actor transition and multi-protocol examples in the roadmap
  • note that the repo currently lacks a connection actor implementation
  • fix formatting errors in the roadmap tables

Testing

  • mdformat-all
  • markdownlint *.md **/*.md
  • nixie *.md docs/*.md
  • make fmt
  • make lint
  • make test

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

Summary by Sourcery

Update documentation to describe stateful connection actor design and server-initiated packet support with multi-protocol examples, and refine the development roadmap accordingly.

New Features:

  • Add a dedicated Use Cases section detailing server-initiated MySQL packets, WebSocket heart-beat pings, and broker-side MQTT PUBLISH examples.

Enhancements:

  • Clarify transition from per-request worker tasks to persistent connection actors with biased select loops.
  • Note absence of a connection actor implementation and outline steps to integrate push queues in the roadmap.
  • Fix formatting inconsistencies in the roadmap tables.

Summary by CodeRabbit

  • Documentation
    • Expanded and clarified the architectural design document, including new explanations of the actor model and its benefits.
    • Added a new section detailing practical use cases enabled by the asynchronous push design.
    • Updated the development roadmap with an introductory note on current implementation status and improved formatting for technical clarity.
    • Enhanced task descriptions for precision and provided more detailed examples in the roadmap.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 24, 2025

Reviewer's Guide

This PR refactors the outbound messaging design by converting per-request workers into stateful connection actors with a biased select! loop, updates the development roadmap to note the missing actor implementation and include multi-protocol examples, adds concrete Use Cases for server-initiated MySQL packets, WebSocket heart-beats and MQTT publishes, and corrects Markdown table formatting in the roadmap.

Sequence diagram for server-initiated MySQL packet push

sequenceDiagram
    participant AppTask as Application Task
    participant SessionRegistry
    participant ConnectionActor
    participant Socket
    AppTask->>SessionRegistry: get PushHandle for session
    AppTask->>ConnectionActor: push(OK packet or LOCAL INFILE)
    ConnectionActor->>ConnectionActor: queue frame in outbox
    ConnectionActor->>Socket: write frame (when idle or after command completes)
Loading

Sequence diagram for WebSocket heart-beat push

sequenceDiagram
    participant Timer as Heart-beat Timer
    participant ConnectionActor
    participant Socket
    Timer->>ConnectionActor: push_high_priority(Ping frame)
    ConnectionActor->>ConnectionActor: enqueue Ping in high-priority queue
    ConnectionActor->>Socket: write Ping frame (even during response stream)
Loading

Sequence diagram for MQTT broker fan-out using PushHandle

sequenceDiagram
    participant Broker as MQTT Broker
    participant SessionRegistry
    participant ConnectionActor as Client ConnectionActor
    participant Socket
    Broker->>SessionRegistry: get PushHandle for subscriber
    Broker->>ConnectionActor: try_push(PUBLISH frame)
    alt Queue not full
        ConnectionActor->>Socket: write PUBLISH frame
    else Queue full
        ConnectionActor->>ConnectionActor: drop frame
    end
Loading

Class diagram for stateful connection actor and push queue design

classDiagram
    class ConnectionActor {
        - context: ConnectionContext
        - high_priority_queue: mpsc::Receiver<Frame>
        - low_priority_queue: mpsc::Receiver<Frame>
        - response_stream: Stream<Response>
        - shutdown_signal: CancellationToken
        + run()
        + handle_push()
        + handle_response()
    }
    class PushHandle {
        + push(frame: Frame)
        + try_push(frame: Frame)
        + push_with_policy(frame: Frame, policy: PushPolicy)
    }
    class SessionRegistry {
        - sessions: DashMap<SessionId, Weak<ConnectionActor>>
        + register(session_id, actor)
        + get_handle(session_id): Option<PushHandle>
    }
    ConnectionActor o-- PushHandle : exposes
    SessionRegistry o-- PushHandle : provides
    PushHandle ..> ConnectionActor : queues frames
Loading

File-Level Changes

Change Details Files
Transition per-request workers to stateful connection actors with biased select loop
  • Modify Phase 1.3 to describe converting per-request workers into a connection actor with a select!(biased; ...) loop
  • Insert explanatory text in the outbound messaging design doc outlining the actor model and its benefits
docs/wireframe-1-0-detailed-development-roadmap.md
docs/asynchronous-outbound-messaging-design.md
Annotate that no connection actor or write loop is currently implemented
  • Add note in roadmap intro that only push queue utilities exist
  • Add corresponding remark in the asynchronous outbound design doc about the missing actor/write loop
docs/wireframe-1-0-detailed-development-roadmap.md
docs/asynchronous-outbound-messaging-design.md
Introduce concrete push Use Cases for MySQL, WebSocket and MQTT
  • Add a Use Cases section covering server-initiated MySQL packets (e.g. LOCAL INFILE, session trackers)
  • Add a WebSocket heartbeat example using high-priority pushes
  • Add an MQTT broker PUBLISH example leveraging try_push for back-pressure
docs/asynchronous-outbound-messaging-design.md
Fix Markdown table formatting in the development roadmap
  • Normalize table separators and remove stray placeholder rows
  • Update column definitions and alignments for Phases 1–4 task tables
docs/wireframe-1-0-detailed-development-roadmap.md

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 24, 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

The documentation was updated to clarify the transition to an actor-per-connection model for asynchronous outbound messaging, detailing its architecture, use cases, and current implementation status. The roadmap was also revised for clarity, with improved formatting and an introductory note on the current state of implementation.

Changes

File(s) Change Summary
docs/asynchronous-outbound-messaging-design.md Expanded to clarify the actor model, architectural evolution, and added a new section on use cases.
docs/wireframe-1-0-detailed-development-roadmap.md Added introductory note, improved formatting, and clarified task descriptions in the roadmap.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ConnectionActor
    participant PushQueue
    participant Socket

    Client->>ConnectionActor: Initiate connection/request
    ConnectionActor->>PushQueue: Enqueue outbound message
    Note over ConnectionActor: Manages state and push queue
    ConnectionActor->>Socket: Write outbound frame (from queue)
    Socket-->>Client: Delivers outbound message
Loading

Possibly related PRs

  • Implement prioritized push queues #118: Documents and builds upon the prioritized push queue implementation, which underpins the actor-per-connection design and asynchronous outbound messaging described in this PR.

Suggested reviewers

  • codescene-delta-analysis

Poem

In the warren of docs, a new path is drawn,
Actors now manage connections from dusk until dawn.
Push queues at the ready, state held in one paw,
Outbound frames fly, without a single flaw.
A roadmap now clearer, with tasks all in line—
This rabbit approves, and the future looks fine! 🐇

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch codex/refactor-connection-write-loop

🪧 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 - here's some feedback:

  • The roadmap tables have leftover empty separator rows and inconsistent column spacing; please clean up redundant divider lines to ensure proper markdown table rendering.
  • After adding the new “Use Cases” section, the header numbering and table of contents are out of sync—please adjust levels and ToC entries for consistency.
  • There are multiple notes about the missing connection actor implementation; consider consolidating them into a single status note to avoid repetition.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The roadmap tables have leftover empty separator rows and inconsistent column spacing; please clean up redundant divider lines to ensure proper markdown table rendering.
- After adding the new “Use Cases” section, the header numbering and table of contents are out of sync—please adjust levels and ToC entries for consistency.
- There are multiple notes about the missing connection actor implementation; consider consolidating them into a single status note to avoid repetition.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c29f07d and cf739cd.

📒 Files selected for processing (2)
  • docs/asynchronous-outbound-messaging-design.md (3 hunks)
  • docs/wireframe-1-0-detailed-development-roadmap.md (2 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/asynchronous-outbound-messaging-design.md

[style] ~19-~19: Would you like to use the Oxford spelling “synchronization”? The spelling ‘synchronisation’ is also correct.
Context: ...istent state awkward and required extra synchronisation when multiple tasks needed to write to ...

(OXFORD_SPELLING_Z_NOT_S)


[style] ~62-~62: Would you like to use the Oxford spelling “centralizing”? The spelling ‘centralising’ is also correct.
Context: ...tead of writing directly to the socket, centralising all output in one place. ### 3.1 Prior...

(OXFORD_SPELLING_Z_NOT_S)


[misspelling] ~381-~381: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...ponse model. Each connection task owns an mpsc outbox channel and exposes a `Sess...

(EN_A_VS_AN)

docs/wireframe-1-0-detailed-development-roadmap.md

[typographical] ~26-~26: To join two clauses or introduce examples, consider using an em dash.
Context: ... | Small | - | | 1.2 | Priority Push Chan...

(DASH_RULE)


[typographical] ~27-~27: To join two clauses or introduce examples, consider using an em dash.
Context: ... | Medium | - | | 1.3 | Connection Actor W...

(DASH_RULE)


[style] ~28-~28: Consider using the typographical ellipsis character here instead.
Context: ...stateful connection actors. Implement a select!(biased; ...) loop that polls for shutdown signals,...

(ELLIPSIS)


[uncategorized] ~28-~28: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...p that polls for shutdown signals, high/low priority pushes and the handler response stream ...

(EN_COMPOUND_ADJECTIVE_INTERNAL)


[typographical] ~29-~29: To join two clauses or introduce examples, consider using an em dash.
Context: ... | Medium | - | | 1.5 | Basic FragmentAdap...

(DASH_RULE)


[uncategorized] ~30-~30: Possible missing comma found.
Context: ...for a single, non-multiplexed stream of fragments and the outbound logic for splitting a ...

(AI_HYDRA_LEO_MISSING_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-test
🔇 Additional comments (4)
docs/wireframe-1-0-detailed-development-roadmap.md (1)

12-16: Introductory note greatly improves reader orientation
Clear statement of current implementation status and immediate next steps reads well and sets expectations.

docs/asynchronous-outbound-messaging-design.md (3)

18-24: Good justification for actor model
Clear explanation of why per-connection actors simplify state management and concurrency.


30-35: Helpful implementation guide
Explicitly pointing readers at src/push.rs and the planned biased select! loop gives concrete next actions — nice touch.


58-64: British spelling consistent with project – no change needed
“Centralising” matches en-GB style already used elsewhere in the docs.

Comment thread docs/wireframe-1-0-detailed-development-roadmap.md
Comment thread docs/wireframe-1-0-detailed-development-roadmap.md Outdated
Comment thread docs/wireframe-1-0-detailed-development-roadmap.md Outdated
Comment thread docs/asynchronous-outbound-messaging-design.md Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
leynos and others added 2 commits June 24, 2025 13:13
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@leynos leynos merged commit e0e20b2 into main Jun 24, 2025
5 checks passed
@leynos leynos deleted the codex/refactor-connection-write-loop branch June 24, 2025 12:26
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