Skip to content

Refactor: Pass shutdown receiver by value instead of mutable reference in worker tasks #36

@coderabbitai

Description

@coderabbitai

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions