Skip to content

v0.13.0

Latest

Choose a tag to compare

@github-actions github-actions released this 20 Nov 14:34
Immutable release. Only release title and notes can be modified.
a69596a

Added

  • Several initial steps. More than one step can set initial true. AshWorkflow.Transformers.AddStateMachine passes every initial step to the state machine's initial_states, and a create action starts a record in one with change transition_state(:step). A create that sets no state starts in the first initial step by declaration order. The reachability check in AshWorkflow.Verifiers.ValidateWorkflow starts from every initial step. A step reached only from a second initial step is no longer reported as unreachable. AshWorkflow.Info.initial_steps/1 and AshWorkflow.Entities.Step.find_initials/1 list the initial steps, and AshWorkflow.Info.workflow_graph/1, the charts and the Clarity overview mark each of them.
  • every can fire at a wall-clock time in the record's own time zone, instead of measuring an interval from its last fire. at ~T[09:00:00] names the local time, on [:mon, :tue, :wed, :thu, :fri] names the days, and time_zone :candidate_time_zone names the attribute holding the zone, or takes a literal such as "Australia/Sydney". A per-record zone is the case a global cron cannot express: two records in the same step fire at 09:00 in their own zones, at two different instants. AshWorkflow.Verifiers.ValidateEvery rejects an every declaring neither. Firing writes the same last_fired_field column, and until still bounds it against state_entered_at.
  • interval alongside at is a stride: how many local days must separate two fires. on says which days carry an occurrence and the stride says how many of them to skip, so interval {14, :days} with on [:mon] is 09:00 every second Monday. A stride must be given in :days, and counts local dates rather than elapsed duration — firing at 09:00 writes the last-fired column microseconds after 09:00, so a duration comparison would find the occurrence exactly one stride later ineligible by that margin and slip the fire a week.
  • AshWorkflow.WallClock computes the occurrences behind at. A local time daylight saving skipped still fires that day, at the instant the clock jumped to; a local time that happens twice fires on the first of the two. A missed occurrence fires late rather than being skipped. AshWorkflow.Scheduler.Precise arms its timers from it and AshWorkflow.Calculations.PendingDeadlines reports the next occurrence from it, so both run on any data layer. AshWorkflow.Scheduler.Oban asks the same question in SQL, with an AT TIME ZONE fragment reading the zone out of each row, so at under that scheduler needs a SQL data layer.
  • time_zone accepts an expression calculation as well as an attribute or a literal, which is how a record reads its zone off a related one: calculate :candidate_time_zone, :string, expr(candidate.time_zone). The calculation must be expression-based, since the zone is read from the trigger's filter — AshWorkflow.Verifiers.ValidateEvery rejects a module calculation, the same check AshWorkflow.Verifiers.ValidateTimeoutFields already applies to a timeout's field. AshWorkflow.Scheduler.Precise.Timeline and AshWorkflow.Calculations.PendingDeadlines load a calculated zone before reading it.
  • at needs a time zone database in the host application, such as config :elixir, :time_zone_database, Tz.TimeZoneDatabase. AshWorkflow.Verifiers.ValidateEvery checks a literal time_zone against it at compile time. A record holding a zone the database does not know arms nothing and reports no pending deadline, rather than raising.

Changed

  • The unreachable-step error names the initial step it searched from ("not reachable from the initial step :review") rather than "the first step".
  • AshWorkflow.Verifiers.ValidateWorkflow no longer raises "Only one step can have initial: true".
  • AshWorkflow.Verifiers.ValidateWorkflow rejects a create action whose transition_state names a step that is not initial. Before, the create failed at runtime.
  • AshWorkflow.Verifiers.ValidateWorkflow rejects an upserting create action that calls transition_state. ash_state_machine only lets an upsert move to a state that a transition declares for that action, and a workflow declares none for creates.
  • The unreachable-step error suggests initial true for an unreachable step that no other step leads into.