TemporalEx.Converter.Schedule (temporal_ex v0.2.1)

Copy Markdown

Helpers for building Temporal Schedule protobuf types from plain Elixir values.

Summary

Functions

Builds a Temporal.Api.Schedule.V1.CalendarSpec from keyword options.

Builds a Temporal.Api.Schedule.V1.IntervalSpec.

Converts a friendly overlap policy atom to the protobuf enum value.

Builds a Temporal.Api.Schedule.V1.Range.

Builds a Temporal.Api.Schedule.V1.Schedule from keyword options.

Builds a Temporal.Api.Schedule.V1.ScheduleAction with a start_workflow action.

Builds a Temporal.Api.Schedule.V1.SchedulePatch from keyword options.

Builds a Temporal.Api.Schedule.V1.SchedulePolicies from keyword options.

Builds a Temporal.Api.Schedule.V1.ScheduleSpec from keyword options.

Builds a Temporal.Api.Schedule.V1.ScheduleState from keyword options.

Builds a Temporal.Api.Schedule.V1.StructuredCalendarSpec from keyword options.

Functions

to_calendar_spec(opts)

Builds a Temporal.Api.Schedule.V1.CalendarSpec from keyword options.

Options

All fields are cron-like strings (e.g., "0", "*/5", "1,15"):

  • :second, :minute, :hour
  • :day_of_month, :month, :year
  • :day_of_week
  • :comment

to_interval_spec(opts)

Builds a Temporal.Api.Schedule.V1.IntervalSpec.

Accepts a keyword list with :every (required, seconds) and :offset (optional, seconds).

to_overlap_policy(value)

Converts a friendly overlap policy atom to the protobuf enum value.

to_range(opts)

Builds a Temporal.Api.Schedule.V1.Range.

Accepts a keyword list with :start, :end (defaults to :start), and :step (defaults to 1), or a bare integer as shorthand for an exact match (5 is equivalent to [start: 5, end: 5, step: 1]).

to_schedule(opts, converter)

Builds a Temporal.Api.Schedule.V1.Schedule from keyword options.

Options

to_schedule_action(opts, converter)

Builds a Temporal.Api.Schedule.V1.ScheduleAction with a start_workflow action.

Options

  • :workflow_type — Workflow type name (required)
  • :task_queue — Task queue name (required)
  • :workflow_id — Workflow ID (required)
  • :args — List of workflow arguments
  • :execution_timeout — Max total time in seconds
  • :run_timeout — Max single run time in seconds
  • :task_timeout — Max task processing time in seconds
  • :retry_policy — Retry policy keyword list
  • :memo — Memo map
  • :search_attributes — Search attributes map

to_schedule_patch(opts)

Builds a Temporal.Api.Schedule.V1.SchedulePatch from keyword options.

Options

  • :pause — String note for pausing
  • :unpause — String note for unpausing
  • :trigger_immediately — Boolean or keyword list with :overlap_policy
  • :backfill — List of backfill request keyword lists

to_schedule_policies(opts)

Builds a Temporal.Api.Schedule.V1.SchedulePolicies from keyword options.

Options

  • :overlap_policy — Overlap policy atom (e.g., :skip, :buffer_one, :cancel_other, :terminate_other, :allow_all)
  • :catchup_window — Catchup window in seconds
  • :pause_on_failure — Boolean
  • :keep_original_workflow_id — Boolean. When true, each scheduled run uses the action's configured workflow ID verbatim instead of appending a timestamp suffix. Required for deployments that rely on fixed workflow IDs for conflict or reuse semantics.

to_schedule_spec(opts)

Builds a Temporal.Api.Schedule.V1.ScheduleSpec from keyword options.

Options

  • :intervals — List of interval specs [every: seconds] or [every: seconds, offset: seconds]
  • :calendars — List of (deprecated string-based) calendar spec keyword lists
  • :structured_calendars — List of structured calendar spec keyword lists (see to_structured_calendar_spec/1)
  • :exclude_calendars — List of (deprecated string-based) calendar specs to exclude (blackout windows)
  • :exclude_structured_calendars — List of structured calendar specs to exclude
  • :cron_expressions — List of cron expression strings
  • :start_timeDateTime when the schedule becomes active
  • :end_timeDateTime when the schedule stops
  • :jitter — Max random jitter in seconds
  • :timezone — Timezone name string (e.g., "America/Chicago")

Exclusion fields mark blackout windows: the schedule does not fire when the current time matches an excluded calendar.

to_schedule_state(opts)

Builds a Temporal.Api.Schedule.V1.ScheduleState from keyword options.

Options

  • :paused — Boolean
  • :notes — String
  • :limited_actions — Boolean
  • :remaining_actions — Integer

to_structured_calendar_spec(opts)

Builds a Temporal.Api.Schedule.V1.StructuredCalendarSpec from keyword options.

Each field accepts a list of ranges (see to_range/1), for example minute: [[start: 0, end: 59, step: 5]] or a shorthand hour: [9] meaning "exactly hour 9". Omitted (or empty-list) fields are filled with cron-style wildcards so the spec actually matches: time fields default to 0, date fields to their full range, and :year defaults to "all years".

Options

  • :second, :minute, :hour
  • :day_of_month, :month, :year
  • :day_of_week (0 = Sunday, 6 = Saturday)
  • :comment

Examples

# Every 15 minutes throughout each day, every day:
Schedule.to_structured_calendar_spec(minute: [[start: 0, end: 59, step: 15]])

# 09:30 every weekday:
Schedule.to_structured_calendar_spec(
  hour: [9], minute: [30], day_of_week: [[start: 1, end: 5]]
)