Skip to content

policy

Stateless reaction that emits Commands when an Event fires. See Concepts: Policy.

Fields

Field Required Description
apiVersion yes schema.esdm.io/core/v1
kind yes policy
name yes The Policy name.
scope yes scope.domain reference.
deliveryGuarantee yes at-least-once or at-most-once.
idempotency required when deliveryGuarantee is at-least-once The idempotency strategy.
handles yes Non-empty list of Event references.
emits yes Non-empty list of Command references (full boundedContext/aggregate/command triples).
constraints no Named rules under which the Policy fires (or doesn't).
description no Free-form prose.
metadata no Non-semantic labels and annotations.

A Policy is stateless. For stateful, multi-Event coordination with timers and lifecycle, use a Process Manager.

Example

apiVersion: schema.esdm.io/core/v1
kind: policy
name: assign-handicap-on-round-completion
scope:
  domain: golf-club-management
deliveryGuarantee: at-least-once
idempotency:
  strategy: deduplication-key
  key: roundId
handles:
  - boundedContext: round-play
    aggregate: round
    event: round-completed
emits:
  - boundedContext: player-profile
    aggregate: handicap-history
    command: record-round-result