View Source Lightning.Runs.Query (Lightning v2.10.4)

Query functions for working with Runs

Summary

Functions

Query to return runs that are eligible for claiming.

Query to return a list of runs that are either in progress (started or claimed) or available.

Return all runs that have been claimed by a worker before the earliest acceptable start time (determined by the run options and grace period) but are still incomplete.

Functions

@spec eligible_for_claim() :: Ecto.Queryable.t()

Query to return runs that are eligible for claiming.

Uses in_progress_window/0 and filters for runs that are either in the available state and have not reached the concurrency limit for their workflow.

Note

This query does not currently take into account the priority of the run. To allow for prioritization, the query should be updated to order by priority.

eligible_for_claim() |> prepend_order_by([:priority])
@spec in_progress_window() :: Ecto.Queryable.t()

Query to return a list of runs that are either in progress (started or claimed) or available.

The select clause includes:

  • id, the id of the run
  • state, the state of the run
  • row_number, the number of the row in the window, per workflow
  • limit, the maximum number of runs that can be claimed for the workflow
@spec lost() :: Ecto.Queryable.t()

Return all runs that have been claimed by a worker before the earliest acceptable start time (determined by the run options and grace period) but are still incomplete.

This indicates that we may have lost contact with the worker that was responsible for executing the run.

@spec lost_steps() :: Ecto.Queryable.t()