Innmind / witness

Actor Model meets PHP
https://innmind.github.io/witness/
MIT License
0 stars 0 forks source link

Rebuild the structure #1

Open Baptouuuu opened 8 months ago

Baptouuuu commented 8 months ago

Overhaul

This package should be rebuilt from scratch around the mantle asynchronous framework. This would allow to work on each actor as if it were synchronous, thus creating a simple architecture.

Actor interface

interface Actor
{
    public function __invoke(Receive $receive): Receive;
}
Receive::message(T)|Receive::signal(Signal)
    ->on(T::class, callable(T, Address(sender)): void)
    ->onChildFailure(callable(Address(child)): void)
    ->onPostStop(callable(): void)
    ->onPreRestart(callable(): void)
    ->onTerminated(callable(Address(child)): void)
    ->stopWhen(callable(): bool);

This style allows for a more declarative approach and may help optimize the system by not calling the callables when declared.

Baptouuuu commented 8 months ago

Instead of using Receive::stopWhen() maybe the continuation pattern should be used on each callable passed to Receive