SP
Size: a a a
SP
D
SP
D
SB
D
SP
class EscalationPolicy implements Saga
{
private int $escalationLevel = 0;
public static function configureSaga(SagaConfiguration $saga)
{
$saga
->canBeStartedBy(CriticalAlert::class)
->correlatesWith(fn(CriticalAlert $event) => $event->alertId)
->correlatesWith(fn(AlertAcknoleged $event) => $event->alertId)
->correlatesWith(fn(AlertResolved $event) => $event->alertId);
}
public function whenWeSeeCriticalAlert(CriticalAlert $event, Context $context)
{
$context->send(new NotifyOnCallProviders())
$context->scheduleTimeout(DateTimeInterval::createFromString('5 minutes'), new EscalationPeriod($event->alertId))
}
public function whenEscalationNotNeeded(AlertAcknoleged | AlertResolved $event, Context $context)
{
$context->completeSaga();
}
public function whenEscalationPeriodPassed(EscalationPeriod $event, Context $context)
{
$this->escalationLevel++;
$context->send(new EscalateQuickly($this->escalationLevel, $event->alertId));
}
}
SP
SP
SP
VK
MM
SB
VK
MM