EntityRefFactory
in package
FinalYes
Spawns and caches one ActorRef per entity identity, enforcing a single writer per entity within an ActorSystem. Subsequent calls to of() with the same id return the cached ref.
Tags
Table of Contents
Methods
- deriveName() : string
- Derive the deterministic actor name for a given entity class and id.
- for() : EntityRefFactoryBuilder<U, object>
- Entry point for the fluent builder.
- instantiate() : self
- of() : ActorRef
- Return the ActorRef for the given entity id, spawning it on first call.
Methods
deriveName()
Derive the deterministic actor name for a given entity class and id.
public
static deriveName(string $entityClass, mixed $id) : string
Namespace separators are replaced with dots so the name is path-safe. The separator '--' satisfies ActorPath's NAME_PATTERN ([a-zA-Z0-9_-.]+).
Accepts scalar ids and any object implementing __toString(). Other
objects (e.g. Symfony's Uuid, which is Stringable) work; raw
non-Stringable objects throw because there is no path-safe
representation we can derive automatically.
Parameters
- $entityClass : string
- $id : mixed
Return values
stringfor()
Entry point for the fluent builder.
public
static for(ActorSpawner $spawner, U> $entityClass) : EntityRefFactoryBuilder<U, object>
Parameters
- $spawner : ActorSpawner
- $entityClass : U>
Tags
Return values
EntityRefFactoryBuilder<U, object>instantiate()
public
static instantiate(ActorSpawner $spawner, string $entityClass, EntityManagerFactory $emFactory, Closure $connectionSource, Closure $commandHandler, EntityReplayPolicy $replayPolicy[, Duration|null $receiveTimeout = null ][, Closure|null $connectionRelease = null ]) : self
Parameters
- $spawner : ActorSpawner
- $entityClass : string
- $emFactory : EntityManagerFactory
- $connectionSource : Closure
- $commandHandler : Closure
- $replayPolicy : EntityReplayPolicy
- $receiveTimeout : Duration|null = null
- $connectionRelease : Closure|null = null
Tags
Return values
selfof()
Return the ActorRef for the given entity id, spawning it on first call.
public
of(mixed $id) : ActorRef
Parameters
- $id : mixed