use Phluxor\ActorSystem\Message\Restarting; class ChildActor implements ActorInterface { public function receive(ContextInterface $context): void { $message = $context->message(); switch (true) { case $message instanceof Restarting: $context->logger()->info('restarting...'); break; case $message instanceof Hello: $context->logger()->info('Hello ' . $message->name); throw new \Exception('hi, I am an exception'); break; } } } UISPX&YDFQUJPO -FUJUDSBTI
* Receives a context. * * @param ContextInterface $context The context to receive. * @return void */ public function receive(ContextInterface $context): void; }
child actor or root actor. • spawnNamed method is used to create a named actor. • spawnPre fi x method is used to create an actor with a pre fi x. • When an actor is spawned, Phluxor\ActorSystem\Ref is returned.
Props::fromProducer( fn() => new YourChildActor() ), 'prefix-' ); "TTJHOBOZOBNFUPUIFBDUPS *GZPVBSFVTJOHQFSTJTUFODF BTTJHOBVOJRVFTQFDJ fi DOBNFSBUIFSUIBOBSBOEPNPOF DSFBUFBOBDUPSXJUIBQSF fi Y
It's quite dif fi cult to understand just by listening, so please try it out yourself. • Once you understand it, you can apply it to your regular programming and modeling!