#504·actix

Allow Actors with a SyncContext to be registered in the SystemRegistry

Author: SyttenCreated Jun 17, 2021Updated Aug 23, 2022
Labelshelp wanted

Expected Behavior

Being able to do MySyncActor::from_registry() and have it work like async actors.

Current Behavior

Currently the SystemRegistry can only have actors with a Context. Thus you need another system to keep track of the sync actors and their addresses. This is annoying if you rely mostly on the registry but have a few sync actors for database calls for exemple.

Possible Solution

  • One possible solution is to have an actor to keep track of them (suggested on stackoverflow). It is quite elegant but the gist is old and not working anymore. The main disadvantage is you now need to await the send call to first get the address of the sync actor and then await again to send a message to it.
  • My preferred solution would be to add a set method on the SystemRegistry like:
rust
let addr = SyncArbiter::start(10, || Redis::new("redis://redis").unwrap());
SystemRegistry::set(addr);

Context

A lot of libraries are sync (diesel is the one we use) and likely won't change anytime soon. Currently the SyncContext and SyncArbiter kind of live in their own world and are not well integrated in the whole ecosystem. I propose we change that!