diff --git a/docs/asynchronous-outbound-messaging-design.md b/docs/asynchronous-outbound-messaging-design.md index 2e558797..652a632a 100644 --- a/docs/asynchronous-outbound-messaging-design.md +++ b/docs/asynchronous-outbound-messaging-design.md @@ -178,6 +178,32 @@ sequenceDiagram Note over Outbox: Holds frames while the socket is busy. ``` +### 3.4 Actor state management + +The connection actor polls four sources: a shutdown token, high- and +low-priority push channels, and an optional response stream. Earlier drafts +tracked a boolean for each source, leading to verbose state updates. The actor +now stores each receiver as an `Option` and counts how many sources have closed. + +```rust +enum RunState { + Active, + ShuttingDown, + Finished, +} + +struct ActorState { + run_state: RunState, + closed_sources: usize, + total_sources: usize, +} +``` + +`total_sources` is calculated when the actor starts. Whenever a receiver returns +`None`, it is set to `None` and `closed_sources` increments. When +`closed_sources == total_sources` the loop exits. This consolidation clarifies +progress through the actor lifecycle and reduces manual flag management. + ## 4. Public API Surface The public API is designed for ergonomics, safety, and extensibility. diff --git a/docs/asynchronous-outbound-messaging-roadmap.md b/docs/asynchronous-outbound-messaging-roadmap.md index c14f4de9..e4e30724 100644 --- a/docs/asynchronous-outbound-messaging-roadmap.md +++ b/docs/asynchronous-outbound-messaging-roadmap.md @@ -13,7 +13,9 @@ design documents. - [x] **Connection actor** with a biased `select!` loop that polls for shutdown, high/low queues and response streams as described in [Design §3.2][design-write-loop]. -- [x] **Internal protocol hooks** `before_send` and `on_command_end` invoked +- [ ] **Run state consolidation** using `Option` receivers and a closed source + counter ([Design §3.4][design-actor-state]). +- [X] **Internal protocol hooks** `before_send` and `on_command_end` invoked from the actor ([Design §4.3][design-hooks]). ## 2. Public API and Ergonomics @@ -52,6 +54,7 @@ design documents. - [ ] **User guides and examples** demonstrating server-initiated messaging ([Design §7][design-use-cases]). +[design-actor-state]: asynchronous-outbound-messaging-design.md#34-actor-state-management [design-dlq]: asynchronous-outbound-messaging-design.md#52-optional-dead-letter-queue-dlq-for-critical-messages [design-errors]: asynchronous-outbound-messaging-design.md#5-error-handling--resilience [design-hooks]: asynchronous-outbound-messaging-design.md#43-configuration-via-the-wireframeprotocol-trait