Slide 79
Slide 79 text
readonly class TransferFactory
{
public function __construct(
private ContextInterface $context,
private float $availability,
private int $retryAttempts,
private ProviderInterface $provider,
) {
}
public function createTransfer(
string $actorName,
Ref $fromAccount,
Ref $toAccount,
float $amount,
): SpawnResult {
$props = Props::fromProducer(
fn() => new TransferProcess($fromAccount, $toAccount, $amount, $this->availability),
Props::withReceiverMiddleware(
new EventSourcedFactory($this->provider)
),
Props::withSupervisor(
new OneForOneStrategy(
$this->retryAttempts,
new DateInterval('PT10S'),
new DefaultDecider(),
)
)
);
return $this->context->spawnNamed($props, $actorName);
}
}