Summary
The current implementation passes the shutdown receiver as a mutable reference (&mut shutdown_rx) to worker tasks, which creates unnecessary lifetime complexity and ownership confusion.
Problem
Each worker task owns its own broadcast::Receiver, but the current approach of capturing &mut shutdown_rx inside an async move closure creates an unnecessary lifetime dance and misleads readers about the actual ownership model.
Suggested Solution
Pass the shutdown receiver by value to each worker task so that each worker owns its receiver directly. This would simplify ownership semantics and avoid hidden self-references inside spawned futures.
Context
This issue was identified during code review and affects the worker task spawning logic in the server implementation.
References
Summary
The current implementation passes the shutdown receiver as a mutable reference (
&mut shutdown_rx) to worker tasks, which creates unnecessary lifetime complexity and ownership confusion.Problem
Each worker task owns its own
broadcast::Receiver, but the current approach of capturing&mut shutdown_rxinside anasync moveclosure creates an unnecessary lifetime dance and misleads readers about the actual ownership model.Suggested Solution
Pass the shutdown receiver by value to each worker task so that each worker owns its receiver directly. This would simplify ownership semantics and avoid hidden self-references inside spawned futures.
Context
This issue was identified during code review and affects the worker task spawning logic in the server implementation.
References