roboto.domain.triggers.dispatch#

Module Contents#

class roboto.domain.triggers.dispatch.DispatchSlot#

One target of one trigger at one dedup token: the unit a dispatch claims.

At most one dispatch ever occupies a slot. It is the dispatch table’s primary key and the vocabulary every dispatch port speaks.

idempotency_token: str#
target_id: str#
trigger_id: str#
class roboto.domain.triggers.dispatch.TriggerDispatchRecord(/, **data)#

Bases: pydantic.BaseModel

Wire-transmissible representation of one trigger dispatch.

A dispatch is one attempt to run one target of one trigger for one matched platform event, deduped at the trigger’s OncePer. The triple (trigger_id, idempotency_token, target_id) is the DispatchSlot; at most one dispatch ever occupies a slot, which is what makes redelivered events safe.

Parameters:

data (Any)

claimed_at: datetime.datetime#

When the slot was (most recently) claimed.

dataset_id: str | None = None#

The dataset the subject belongs to (the subject itself for a dataset event), which is what a dataset’s page lists dispatches by. None when the subject has no dataset, such as a session or an invocation.

event_id: str#

Id of the platform event occurrence that most recently claimed this slot.

event_type: roboto.domain.platform_events.PlatformEventType#

Type of the platform event that matched.

finalized_at: datetime.datetime | None = None#

When the dispatch reached a terminal status; None while claimed.

idempotency_token: str#

Dedup token derived from the matched event at the trigger’s once_per ({event.type}|{once_per}:{projection}).

org_id: str#

Organization that owns the trigger.

result_ref: str | None = None#

an invocation id, an agent thread id, or a Slack message timestamp, per target_type.

Type:

What a dispatched target produced

property slot: DispatchSlot#

The slot this dispatch occupies.

Return type:

DispatchSlot

status: TriggerDispatchStatus#

Where this dispatch is in its lifecycle.

status_detail: str | None = None#

Human-readable detail for status, e.g. the error a failed target raised.

subject: str#

The entity the matched platform event was about, as a roboto:// URI; the same value as the event’s own subject.

property subject_uri: roboto.uri.RobotoUri#

subject as a parsed RobotoUri.

Return type:

roboto.uri.RobotoUri

target_id: str#

Which of the trigger’s targets this dispatch ran.

target_type: roboto.domain.triggers.targets.TriggerTargetType#

Kind of target dispatched.

trigger_id: str#

Trigger this dispatch belongs to.

class roboto.domain.triggers.dispatch.TriggerDispatchStatus#

Bases: roboto.compat.StrEnum

Lifecycle state of one dispatch: one attempt to run one target for one matched event.

Claimed = 'claimed'#

The dispatch slot is claimed and the target is about to run. A claim that neither finalizes nor is reclaimed within the redelivery grace period is presumed dead and may be claimed again, so delivery is at-least-once: a target may run twice for one event.

Dispatched = 'dispatched'#

The target ran; TriggerDispatchRecord.result_ref points at what it produced.

Failed = 'failed'#

The target raised; a redelivered event may claim the slot again.

Unknown = 'unknown'#

The claim outlived every redelivery of its event without finalizing, so the outcome cannot be determined. Set by an operational sweep, never reclaimable.