Skip to content
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

feat!: add on_message hook to Actor trait #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tqwewe
Copy link
Owner

@tqwewe tqwewe commented Oct 21, 2024

This PR introduces a new on_message hook to the Actor trait.

Overview:

The on_message method allows actors to customize how incoming messages are handled. By default, the method processes the message immediately using the actor’s standard message handling logic (msg.handle_dyn). However, this method is designed to offer flexibility for advanced use cases where immediate handling may not be ideal. For example, developers can override on_message to:

  • Buffer messages for delayed processing.
  • Implement custom scheduling or prioritization logic.
  • Manipulate or filter raw messages before they are handled.

Key Changes:

  • New on_message Method: Handles the incoming message, with the option to override for custom processing behavior.
  • Default Behavior: Processes the message using msg.handle_dyn(self, actor_ref, tx).await.
  • Advanced Use Cases: Supports scenarios where buffering or deferring message handling is required.

This addition provides more control over how messages are processed, enhancing the flexibility of actor behavior in complex systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant