WardrikTriggers. Trigger
(wardrik_triggers v0.1.0-rc.1)
Copy Markdown
A trigger: when to ask an agent, and what. Decoded from a map with string keys, as an agent file writes it.
{:ok, trigger} =
WardrikTriggers.Trigger.decode(%{
"name" => "daily",
"every" => "0 9 * * *",
"timezone" => "America/Los_Angeles",
"prompt" => "Write today's update."
})See the README for every key.
Summary
Functions
Decodes a trigger from fields.
Encodes the trigger as a map with string keys. Leaves out unset keys and the default timezone.
Types
@type status() :: :asked | :nothing_new | :busy | :no_agent | :missed | :failed
How a run went. Matches the protocol's trigger.fired status.
@type t() :: %WardrikTriggers.Trigger{ clock: WardrikTriggers.Clock.t() | nil, every: String.t() | nil, feeds: [String.t()], jitter: non_neg_integer(), missed: :run_once | :skip, name: String.t(), overlap: :skip | :queue, prompt: String.t() | nil, prompt_file: String.t() | nil, timezone: String.t(), webhook: %{secret: String.t(), verify: :shared | :standard} | nil }
Functions
@spec decode(map(), pos_integer()) :: {:ok, t()} | {:error, String.t()}
Decodes a trigger from fields.
Without a "name", the name comes from index: trigger-1, trigger-2 and so on. Returns
{:error, message} for an unknown key or invalid value.
Encodes the trigger as a map with string keys. Leaves out unset keys and the default timezone.