nexus-core
Foundational actor model abstractions: ActorSystem, Behavior, Props, ActorRef, supervision, lifecycle signals, and the full exception hierarchy.
What's in this package
Actor namespace (Monadial\Nexus\Core\Actor\)
ActorSystem— entry point; spawns top-level actors and drives the runtimeActorRef<T>— type-safe reference;tell(),ask(),path(),isAlive()ActorContext<T>— handler context; spawn, stop, watch, schedule, stash, logBehavior<T>— immutable behavior definition;receive,withState,setup,same,stopped,unhandledBehaviorWithState<T,S>— result type for stateful handlers;next,same,stopped,withBehaviorProps<T>— spawn configuration;fromBehavior,fromFactory,fromContainer,fromStatefulFactoryActorHandler<T>,StatefulActorHandler<T,S>,AbstractActor<T>— class-based actor interfacesActorCell<T>,LocalActorRef<T>,DeadLetterRef— internal engine and ref implementationsActorPath,ActorState— path and state-machine types
Supervision namespace (Monadial\Nexus\Core\Supervision\)
SupervisionStrategy—oneForOne,allForOne,exponentialBackoffDirectiveenum —Restart,Stop,Resume,Escalate
Lifecycle namespace (Monadial\Nexus\Core\Lifecycle\)
Message namespace (Monadial\Nexus\Core\Message\)
Exception namespace (Monadial\Nexus\Core\Exception\)
NexusException,ActorInitializationException,AskTimeoutException,MaxRetriesExceededException,InvalidActorPathException,InvalidActorStateTransition
Install
composer require nexus-actors/core
Quick example
src/Actor/GreeterActor.php
use Monadial\Nexus\Core\Actor\ActorSystem;
use Monadial\Nexus\Core\Actor\Behavior;
use Monadial\Nexus\Core\Actor\Props;
use Monadial\Nexus\Runtime\Fiber\FiberRuntime;
$runtime = new FiberRuntime();
$system = ActorSystem::create('app', $runtime);
$behavior = Behavior::receive(static fn ($ctx, $msg) => Behavior::same());
$ref = $system->spawn(Props::fromBehavior($behavior), 'greeter');
$ref->tell(new Greet('world'));
$system->run();
See also
- Core concepts / actors
- Core concepts / behaviors
- Core concepts / supervision
- nexus-runtime —
Duration, mailbox contracts, and theRuntimeinterface