Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Checking message transmissibility at compile time #26

Open
RedKinda opened this issue Jun 5, 2023 · 2 comments
Open

Checking message transmissibility at compile time #26

RedKinda opened this issue Jun 5, 2023 · 2 comments

Comments

@RedKinda
Copy link
Contributor

RedKinda commented Jun 5, 2023

Would it make sense to create a trait with something like RemoteMessage: Message, and move the into_remote_envelope and into_remote_envelopeinto it? Currently it just defaults to Err(NotTransmissible) which is not great and throws an error at runtime. Doing this would allow changing with_handler<A: Actor, M: Message> into with_handler<A: Actor, M: RemoteMessage>, which would alert user about this at compile time.

@LeonHartley
Copy link
Owner

Hey @RedKinda. I agree, it's a nice suggestion - the more that fails at compile-time the better. The only issue I can see is that when using the ActorRef struct, the underlying actor can be a RemoteActorRef, or a LocalActorRef - the send and notify methods both accept M: Message. I'm not sure how it'd be possible to still allow location-transparent actor refs, when forcing remote messages implement a separate trait.

https://github.com/LeonHartley/Coerce-rs/blob/master/coerce/src/actor/refs/mod.rs#L124

@RedKinda
Copy link
Contributor Author

RedKinda commented Jun 5, 2023

Would it make sense to make a send_local() function that takes Message and would error out if its a RemoteActorRef? Then you could require RemoteMessage on send(). This would only have to change in feature = "remote" environments. This solution would still produce a runtime error, but instead of throwing it when sending a non-remotable message, it would throw when using send_local on remote actors. This is in my opinion a worthwhile tradeoff, since user has to explicitly specify that it's local only.

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

No branches or pull requests

2 participants