View Source Lightning.Runs.Query (Lightning v2.11.1)
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.
It returns a row_number (sequential number) for each run partitioned (grouped by) workflow or project. If workflow concurrency is set it takes precedence over project concurrency.
Note that this query does NOT consider the smaller concurrency once it's not enough to assure that project concurrency is always respected (e.g when 2 workflows of same project have concurrency 3 on a project with concurrency 5, 3 is less than 5 but still project concurrency wouldn't be respected). Instead the LV makes sure that a workflow concurrency sum does not exceed the project concurrency.
The select clause includes:
id
, the id of the runstate
, the state of the runrow_number
, the number of the row in the window, per workflow or per projectconcurrency
, 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()