-
Notifications
You must be signed in to change notification settings - Fork 5
docs: add API redesign plan for v0.5 #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
41e4b62
a39ce76
fa724c8
1ef33bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,14 +187,17 @@ pub enum ExitReason { | |
| **New file:** `concurrency/src/traits.rs` | ||
|
|
||
| ```rust | ||
| /// Trait for actors that can be supervised | ||
| /// Trait for actors that can be supervised. | ||
| /// Provides actor_id() for identity comparison with trait objects. | ||
| pub trait Supervisable: Send + Sync { | ||
| fn actor_id(&self) -> ActorId; | ||
| fn stop(&self); | ||
| fn is_alive(&self) -> bool; | ||
| fn on_exit(&self, callback: Box<dyn FnOnce(ExitReason) + Send>); | ||
| } | ||
|
|
||
| /// Trait for actors that can be linked | ||
| /// Trait for actors that can be linked. | ||
| /// Uses actor_id() (from Supervisable) to track links internally. | ||
| pub trait Linkable: Supervisable { | ||
| fn link(&self, other: &dyn Linkable); | ||
| fn unlink(&self, other: &dyn Linkable); | ||
|
|
@@ -240,7 +243,10 @@ pub trait Message: Send + 'static { | |
| type Result: Send; | ||
| } | ||
|
|
||
| /// Handler for a specific message type | ||
| /// Handler for a specific message type. | ||
| /// Uses RPITIT (Rust 1.75+) — this is fine since Handler is never used as dyn. | ||
| /// &mut self is safe: actors process messages sequentially (one at a time), | ||
| /// so there is no concurrent access to self. | ||
| pub trait Handler<M: Message>: Actor { | ||
| fn handle(&mut self, msg: M, ctx: &Context<Self>) -> impl Future<Output = M::Result> + Send; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: docs/API_REDESIGN.md
Line: 205:205
Comment:
The `Handler::handle` signature uses RPITIT. Also note that using `&mut self` in async contexts may cause issues with concurrent message handling. Consider documenting that messages are processed sequentially per actor to clarify this design choice.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a doc comment clarifying: RPITIT is fine here since |
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
linkandunlinkmethods take&dyn Linkable, which requires identity comparison to track links. Consider documenting how actor identity/equality works with trait objects, or including anactor_id()method in the trait for proper tracking.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
actor_id()toSupervisabletrait.Linkable::link/unlinkuse this for identity tracking internally.