roboto.domain.triggers.namespace#
Module Contents#
- roboto.domain.triggers.namespace.CHANGED_ROOT = 'changed'#
the metadata fields an update event put, keyed by field name.
- Type:
Delta root
- roboto.domain.triggers.namespace.ENVELOPE_ROOT = 'envelope'#
its id, source, subject, type, time, and org. Reserved: no event type may expose it as an entity root.
- Type:
Namespace root served from the platform event’s own envelope
- class roboto.domain.triggers.namespace.EventNamespace(event, source, *, trigger=None, _records=None)#
Resolves dotted variable paths against a platform event.
The one namespace with three consumers: condition evaluation (whole records via
record()), target template substitution (single paths viaresolve(), satisfying theVariableResolverprotocol), and idempotency projections. Entity-backed roots hydrate through theNamespaceSourceat most once each and are cached for the namespace’s lifetime — includingNoneresults. Theenvelope,changed, andtagroots are served from the event itself and never touch the source;triggeris served from the bound trigger (seebound_to()) and is otherwise absent.- Parameters:
source (NamespaceSource)
trigger (Optional[roboto.domain.triggers.record.TriggerRecord])
_records (Optional[dict[str, Optional[Mapping[str, Any]]]])
- bound_to(trigger)#
A view of this namespace for one trigger, in which
trigger.*resolves.One namespace is shared across every trigger evaluated for an event so each entity hydrates once; the trigger being evaluated is per-trigger state, so it lives on a view rather than on the shared object. The view delegates every other root to the same hydration cache – reading
dataset.namethrough it and through the parent costs one fetch in total.- Parameters:
trigger (roboto.domain.triggers.record.TriggerRecord) – The trigger whose templates and condition are being evaluated.
- Return type:
- get(path)#
Return the value at dotted
path(e.g.dataset.metadata.vehicle_id), orNone.The first path segment names the root; the rest walk nested mappings. Any missing segment yields
None.- Parameters:
path (str)
- Return type:
Any
- record(root)#
Return the whole record for namespace
root, hydrating it at most once.- Parameters:
root (str) – Namespace root to fetch.
envelopeyields the envelope fields;changedyields the changeset’s put fields;tagyields{"added": [...], "removed": [...]}; any other root delegates to the cachedNamespaceSource.- Returns:
The record as a mapping, or
Nonewhen the source cannot resolve the root.- Return type:
Optional[Mapping[str, Any]]
- resolve(name)#
Return the string form of the value at
namefor template substitution, orNone.- Parameters:
name (str)
- Return type:
Optional[str]
- class roboto.domain.triggers.namespace.NamespaceSource#
Bases:
ProtocolLazily hydrates entity-backed namespace roots for an event.
- record_for_root(root, event)#
Load the entity for namespace
rootas a JSON-able mapping.- Parameters:
root (str) – The namespace root to hydrate (
"dataset","file","invocation","event", …). Never a delta or reserved root: the namespace servesenvelope,trigger,schedule,changedandtagitself.event (roboto.domain.platform_events.PlatformEvent) – The event whose subject identifies the entity to load.
- Returns:
The entity as a mapping, or
Nonewheneventcannot resolve it (no such root for this event type, or the entity was deleted between emit and evaluation).- Return type:
Optional[Mapping[str, Any]]
- roboto.domain.triggers.namespace.TAG_ROOT = 'tag'#
the tags an event added and removed.
- Type:
Delta root
- roboto.domain.triggers.namespace.TRIGGER_ROOT = 'trigger'#
Namespace root describing the trigger being evaluated. Reserved for the consumer; no event type may expose it as an entity root.