keiro-dsl-0.26.0.0: test/fixtures/intake-delegated-noop.keiro
language keiro-dsl 6
context delivery-outcomes
# A delegated intake whose downstream command is sometimes a typed no-op:
# a delivery status never moves backwards, so recording an outcome after the
# delivery is final changes nothing. The hand-written handler runs the command
# through Keiro.Inbox.Delegated.delegatedDomainCommand, which acknowledges the
# no-op with a completed inbox row instead of a marker event.
contract courier {
schemaVersion 1
discriminator messageType
topic deliveryEvents "courier.delivery.events"
event DeliveryOutcomeReported on deliveryEvents {
deliveryId: text
outcome: text
}
}
intake deliveryOutcomeInbox {
contract courier
topic deliveryEvents
accept DeliveryOutcomeReported
bind source from header "keiro-source" required
bind schemaVersion from header "keiro-schema-version" required cross-check body
bind messageId from header "keiro-message-id" required cross-check body
bind key from kafka-key
bind occurredAt from kafka-cursor
bind idempotencyKey from body
dedupe key messageId policy PreferIntegrationMessageId
idempotence delegated
decode {
envelope strict-required lenient-optional
body strict schemaVersion == 1
}
disposition {
processed => ackOk
duplicate => ackOk
inProgress => retry 5s
previouslyFailed => deadLetter "previous inbox failure"
decodeFailed => deadLetter
dedupeFailed => deadLetter
storeFailed => retry 5s
}
}
enum DeliveryRejection { NeverRejected=never-rejected }
enum DeliveryNoOp { AlreadyFinal=already-final }
aggregate DeliveryStatus
domain-outcomes rejection=DeliveryRejection no-op=DeliveryNoOp
regs
finalOutcome Text = "none"
states Pending Delivered
command RecordOutcome { outcome:Text }
event OutcomeRecorded = fields(RecordOutcome)
Pending -- RecordOutcome -->
write finalOutcome := cmd.outcome
outcome accepted
emit OutcomeRecorded
goto Delivered
Delivered -- RecordOutcome -->
outcome no-op DeliveryNoOp.AlreadyFinal
goto Delivered