tqwewe / kameo

Fault-tolerant Async Actors Built on Tokio
https://docs.page/tqwewe/kameo
Apache License 2.0
634 stars 16 forks source link

[FEATURE] - Add `.wait_startup` method to actor ref #62

Closed tqwewe closed 1 month ago

tqwewe commented 1 month ago

Feature Description

There's currently no synchronization feature for waiting for an actor to be fully started up and ready to receive messages. This feature would add a method .wait_startup().await which allows you to ensure an actor has fully started up.

Motivation

In some cases it might be useful to wait for an actor to be fully started up and ready to process messages.

Proposed Solution

Add a Arc<Notify> to the ActorRef which is notified when the actor finishes its startup process.

Alternatives Considered

Actors can manually add a Arc<Notify> to the state which is notified within the on_startup lifecycle hook.