automata/event/builtin/body
Types
Convenience alias used by ecosystem-wide layers (worker, runtime).
pub type BuiltinEvent =
event.Event(EventBody)
Built-in body sum used by the BuiltinEvent alias.
Closed for known kinds plus a Custom escape hatch. The
FileSystem variant carries an automata/fsevent WatchEvent
so the full set of ops (Create, Write, Remove, Rename,
Chmod) and the rename’s old path can travel together with the
event without callers having to invent ad-hoc body kinds.
pub type EventBody {
Scheduled(
plan_id: String,
fired_at: ast.ValidDateTime,
schedule_kind: ScheduleKind,
)
FileSystem(event: event.WatchEvent)
Manual(
reason: option.Option(String),
actor: option.Option(String),
)
Custom(kind: String, attributes: dict.Dict(String, String))
}
Constructors
-
Scheduled( plan_id: String, fired_at: ast.ValidDateTime, schedule_kind: ScheduleKind, ) -
FileSystem(event: event.WatchEvent) -
Manual( reason: option.Option(String), actor: option.Option(String), ) -
Custom(kind: String, attributes: dict.Dict(String, String))
Distinguishes cron and RRULE plans inside Scheduled so a worker
can branch without inspecting the producing module.
pub type ScheduleKind {
CronSchedule
RRuleSchedule
}
Constructors
-
CronSchedule -
RRuleSchedule
Values
pub fn derived_source(
body: EventBody,
source_id: String,
) -> source.Source
Derive the canonical Source for an EventBody. Exposed so that
callers building events via event.new (for advanced cases like
attaching a source name) can stay consistent with body.new.
pub fn derived_source_kind(body: EventBody) -> source.SourceKind
Map an EventBody to its canonical SourceKind.
pub fn file_system(event event: event.WatchEvent) -> EventBody
Wrap an automata/fsevent WatchEvent in the canonical body.
pub fn kind(body: EventBody) -> String
Stable string label for routing tables, metrics, and structured logs.
FileSystem(_) becomes "file_system:create" for a single-op
event, "file_system:create+write" when several ops are present
(lowercase ops joined by + in canonical order). Custom("kind", _)
becomes "custom:kind".
pub fn manual(
reason reason: option.Option(String),
actor actor: option.Option(String),
) -> EventBody
pub fn new(
id id: String,
occurred_at occurred_at: ast.ValidDateTime,
source_id source_id: String,
body body: EventBody,
) -> event.Event(EventBody)
Construct a BuiltinEvent whose source.kind is derived from
body. This is the only sanctioned constructor for BuiltinEvent
because it makes source/body misclassification unrepresentable —
Scheduled always pairs with ScheduleSource, FileSystem(_) with
FileSystemSource, Custom("vendor.kind", _) with
CustomSource("vendor.kind"), etc.
pub fn scheduled(
plan_id plan_id: String,
fired_at fired_at: ast.ValidDateTime,
schedule_kind schedule_kind: ScheduleKind,
) -> EventBody