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

Allow Actors with a SyncContext to be registered in the SystemRegistry #504

Open
Sytten opened this issue Jun 17, 2021 · 8 comments
Open

Comments

@Sytten
Copy link
Contributor

Sytten commented Jun 17, 2021

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:
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!

@kesavkolla
Copy link

This will really help with multi actor scenarios. Would love to see this feature implemented in the core.

@FireSpoonYZ
Copy link

I think allow actors with a SyncContext can use broker is also necessary. I'm not sure if there's a way to boardcast a message to all actors inside one SyncArbiter.

@kesavkolla
Copy link

Any update on this? I'm also looking for this.

@robjtede
Copy link
Member

actix is in maintenance mode. Project contributors are not actively working on adding features but will still review PRs.

@kesavkolla
Copy link

Oh sad to hear that. It's such a nice library. Does most of the heavy lifting in writing actor code. Infact it's one of the fastest web framework too...

@kesavkolla
Copy link

Is there any pointer here so that I can write that code and generate PR

@robjtede
Copy link
Member

actix has not used within Actix Web for a very long time. The actor framework called actix is largely irrelevant and overly-verbose in today's async landscape. I'd recommend trying to use actor patterns on top of Tokio directly. See https://ryhl.io/blog/actors-with-tokio/.

@Sytten
Copy link
Contributor Author

Sytten commented Aug 23, 2022

We use it extensively for Caido and I agree with @robjtede, we will be migrating at some point. We are considering Xtra which is similar in shape. Still missing a few things like a broker and concurrent handling of requests, but it is better than starting from scratch IMO.

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

No branches or pull requests

4 participants