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() : D>
- 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, U> $entityClass, EntityManagerFactory $emFactory, callable(): Connection $connectionSource, callable(ActorContext<string|int, D>, D, U): EntityEffect<string|int, U> $commandHandler, EntityReplayPolicy $replayPolicy[, Duration|null $receiveTimeout = null ][, callable(Connection): void|null $connectionRelease = null ]) : D>
Parameters
- $spawner : ActorSpawner
- $entityClass : U>
- $emFactory : EntityManagerFactory
- $connectionSource : callable(): Connection
- $commandHandler : callable(ActorContext<string|int, D>, D, U): EntityEffect<string|int, U>
- $replayPolicy : EntityReplayPolicy
- $receiveTimeout : Duration|null = null
- $connectionRelease : callable(Connection): void|null = null
Tags
Return values
D>of()
Return the ActorRef for the given entity id, spawning it on first call.
public
of(mixed $id) : ActorRef
Parameters
- $id : mixed