keiro-dsl-0.17.0.0: test/fixtures/process-state-authority.keiro
language keiro-dsl 6
context incident-response
id IncidentId prefix=inc
enum Severity { Sev1=sev1 Sev2=sev2 Sev3=sev3 }
enum EscalationRejection { Invalid=invalid }
enum EscalationNoOp { Ignored=ignored }
process IncidentEscalation
name "incident-escalation"
reactions version 1
input IncidentReported { incidentId:IncidentId severity:Severity raisedAt:Time }
input ResponderAcked { incidentId:IncidentId ackedAt:Time }
input ResponderIgnored { incidentId:IncidentId }
input IncidentNoted { incidentId:IncidentId }
correlate input.incidentId via idText
saga Escalation category "escalation"
target Incident
projections [ ]
on IncidentReported
when input.severity == Severity.Sev1
advance NoteRaised { incidentId }
schedule escalation fireAt input.raisedAt + 5m { incidentId severity }
otherwise
advance NoteRaised { incidentId }
schedule escalation fireAt input.raisedAt + 60m { incidentId severity }
on ResponderAcked
advance NoteAcknowledged { incidentId }
accepted
dispatch Incident@input.incidentId AcknowledgeIncident { incidentId }
on-appended AckOk ; on-duplicate AckOk ; on-failed Retry
silent no-action
cancel escalation
on ResponderIgnored
advance NoteIgnored { incidentId }
accepted
dispatch Incident@input.incidentId AcknowledgeIncident { incidentId }
on-appended AckOk ; on-duplicate AckOk ; on-failed Retry
silent no-action
cancel escalation
on IncidentNoted
no-action
dispatch-id strategy=uuidv5 from=(name, correlationId, sourceEventId, targetStreamName, occurrence)
rejected => halt
poison => halt
timers max-attempts 5 dead-letter "escalation timer exceeded ceiling"
timer escalation
id uuidv5 "incident-escalation-timer:" <> correlationId
payload { kind="escalation" incidentId:IncidentId severity:Severity }
fire dispatch Incident@correlationId EscalateIncident { incidentId }
fired-event-id uuidv5 "incident-escalation-fired:" <> correlationId
on-ok Fired ; on-reject Fired ; on-ambiguous Retry ; on-error Retry ; not-mine Retry
decode unknown-status => Cancelled
aggregate Escalation
domain-outcomes rejection=EscalationRejection no-op=EscalationNoOp
regs
states Open Dormant
command NoteRaised { incidentId }
command NoteAcknowledged { incidentId }
command NoteIgnored { incidentId }
command ActivateDormant { incidentId }
event RaisedNoted = fields(NoteRaised)
event Acknowledged = fields(NoteAcknowledged)
event DormantActivated = fields(ActivateDormant)
Open -- NoteRaised -->
outcome accepted
emit RaisedNoted
goto Open
Open -- NoteAcknowledged -->
outcome accepted
emit Acknowledged
goto Open
Open -- NoteIgnored -->
outcome no-op EscalationNoOp.Ignored
goto Open
Open -- ActivateDormant -->
outcome accepted
emit DormantActivated
goto Dormant
aggregate Incident
regs
states Open
command AcknowledgeIncident { incidentId }
command EscalateIncident { incidentId }
event IncidentAcknowledged = fields(AcknowledgeIncident)
event IncidentEscalated = fields(EscalateIncident)
Open -- AcknowledgeIncident --> emit IncidentAcknowledged ; goto Open
Open -- EscalateIncident --> emit IncidentEscalated ; goto Open