Decode a lifecycle event: the CloudEvents 1.0 (structured mode) event an Ankusa instance publishes when a source or a route is created, updated or deleted, when a tenant is erased, or when the instance is restored from a backup.
It arrives as the body of a queue message from the instance's lifecycle
sinks (content type application/cloudevents+json, source_id
ankusa:lifecycle): decode the message with ankusa.sdk.message/decode,
take the body from ankusa.sdk.message/->hook, and hand it to decode.
(let [event (lifecycle/decode (:body hook))]
(:type event)) ;=> "io.ankusa.source.created"
Delivery is at least once and in commit order. :id is derived from the
change, so the same event always has the same id, and :revision (per
:subject) lets a consumer ignore a stale update.
Every failure is an :ankusa.sdk/InvalidMessageError with a stable :code
("invalid_json", "not_an_object", "unsupported_version" when the
event's specversion is not "1.0", or "invalid_field" and the
offending :field). It is never retryable.
Decode a lifecycle event: the CloudEvents 1.0 (structured mode) event an Ankusa instance publishes when a source or a route is created, updated or deleted, when a tenant is erased, or when the instance is restored from a backup. It arrives as the body of a queue message from the instance's lifecycle sinks (content type `application/cloudevents+json`, `source_id` `ankusa:lifecycle`): decode the message with `ankusa.sdk.message/decode`, take the body from `ankusa.sdk.message/->hook`, and hand it to `decode`. ```clojure (let [event (lifecycle/decode (:body hook))] (:type event)) ;=> "io.ankusa.source.created" ``` Delivery is at least once and in commit order. `:id` is derived from the change, so the same event always has the same id, and `:revision` (per `:subject`) lets a consumer ignore a stale update. Every failure is an `:ankusa.sdk/InvalidMessageError` with a stable `:code` (`"invalid_json"`, `"not_an_object"`, `"unsupported_version"` when the event's `specversion` is not `"1.0"`, or `"invalid_field"` and the offending `:field`). It is never retryable.
(decode data)Decode and verify one lifecycle event from data, a string or a byte[] of
UTF-8 JSON. Returns
{:specversion :id :source :type :subject :time :datacontenttype :data :revision :actor :instance :sequence :replayid :traceparent :tracestate}
where :data is the entity as the admin API shows it (string keys, secrets
redacted) or nil, :sequence is the instance's audit sequence number as the
decimal string it is on the wire, and every optional field the event omitted
or said null is nil. Unknown keys and event types are ignored, so a
consumer keeps working when a newer node announces more.
The rules run in order and the first failure wins: valid JSON, an object,
specversion 1.0, then the typed fields (id, source, type, subject,
time, datacontenttype, data, revision, actor, instance,
sequence, replayid, traceparent, tracestate). Anything but a string
or byte[] throws IllegalArgumentException.
Decode and verify one lifecycle event from `data`, a string or a `byte[]` of
UTF-8 JSON. Returns
`{:specversion :id :source :type :subject :time :datacontenttype :data
:revision :actor :instance :sequence :replayid :traceparent :tracestate}`
where `:data` is the entity as the admin API shows it (string keys, secrets
redacted) or `nil`, `:sequence` is the instance's audit sequence number as the
decimal string it is on the wire, and every optional field the event omitted
or said `null` is `nil`. Unknown keys and event types are ignored, so a
consumer keeps working when a newer node announces more.
The rules run in order and the first failure wins: valid JSON, an object,
`specversion` 1.0, then the typed fields (`id`, `source`, `type`, `subject`,
`time`, `datacontenttype`, `data`, `revision`, `actor`, `instance`,
`sequence`, `replayid`, `traceparent`, `tracestate`). Anything but a string
or `byte[]` throws `IllegalArgumentException`.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |