Gust. Flows
(gust v0.1.36)
Copy Markdown
The Flows context.
This module serves as the boundary for accessing and manipulating Flow-related data, such as DAGs, Runs, Tasks, and Secrets.
Summary
Functions
Cancels a waiting task by clearing its wait markers and marking it failed in one write.
Returns an %Ecto.Changeset{} for tracking secret changes.
Returns the number of runs associated with a given DAG.
Creates a DAG.
Creates a log.
Creates a run.
Creates a secret.
Creates a task.
Creates a test run.
Creates a test task.
Deletes a DAG.
Deletes all DAGs whose IDs are not in the provided list.
Deletes the given run from the database.
Deletes runs that belong to the given DAG.
Deletes a secret.
Gets a single DAG.
Gets a DAG by name.
Gets a DAG by name with its runs preloaded, with pagination for runs.
Gets a DAG by name with its most recent runs preloaded.
Gets a DAG with its runs preloaded.
Gets a DAG with its runs and tasks preloaded, with pagination for runs.
Gets the requested DAGs with their most recent runs preloaded.
Gets a single log.
Gets logs for a task, optionally filtered by level.
Gets a single run.
Gets a single run with its tasks preloaded.
Gets runs for a list of DAG IDs with the given statuses.
Gets runs by ID that belong to the given DAG.
Gets a single secret.
Gets a single secret by name.
Gets a single task.
Gets a task by name, run ID, and map index.
Gets a task by name and run ID.
Gets a task by name and run ID, with logs preloaded.
Gets all task statuses by name and run ID.
Gets a task with its logs preloaded.
Gets all task instances by name and run ID.
Lists all DAGs.
Lists all secrets.
Updates a resumed waiting task's params, wait state, and status in one write.
Toggles the enabled status of a DAG.
Updates a run status.
Updates the status of multiple runs in one database statement.
Updates a secret.
Updates a task attempt count.
Updates a task error.
Updates a task map index and its persisted parameters.
Updates a task's persisted parameters.
Updates a task result.
Updates a task result and error.
Updates a task status.
Updates a task's persisted wait state.
Functions
Cancels a waiting task by clearing its wait markers and marking it failed in one write.
Returns an %Ecto.Changeset{} for tracking secret changes.
Examples
iex> change_secret(secret)
%Ecto.Changeset{data: %Secret{}}
Returns the number of runs associated with a given DAG.
Parameters
dag_id- The identifier of the DAG whose runs should be counted.
Returns
- The integer count of runs associated with the specified DAG.
Creates a DAG.
Examples
iex> create_dag(%{field: value})
{:ok, %Dag{}}
iex> create_dag(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Creates a log.
Creates a run.
Examples
iex> create_run(%{field: value})
{:ok, %Run{}}
iex> create_run(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Creates a secret.
Examples
iex> create_secret(%{field: value})
{:ok, %Secret{}}
iex> create_secret(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Creates a task.
Creates a test run.
Creates a test task.
Deletes a DAG.
Deletes all DAGs whose IDs are not in the provided list.
Deletes the given run from the database.
The run must be a persisted %Run{} struct. This function delegates to
Repo.delete/1 and returns {:ok, %Run{}} if the run is successfully
deleted, or {:error, %Ecto.Changeset{}} if the delete operation fails.
Examples
iex> delete_run(run)
{:ok, %Run{}}
iex> delete_run(invalid_run)
{:error, %Ecto.Changeset{}}
Deletes runs that belong to the given DAG.
Returns the deleted run structs so callers can update LiveView streams.
Deletes a secret.
Gets a single DAG.
Raises Ecto.NoResultsError if the Dag does not exist.
Gets a DAG by name.
Gets a DAG by name with its runs preloaded, with pagination for runs.
The DAG is looked up by its name. The associated runs are ordered by
descending inserted_at and paginated using the required :limit and
:offset keyword options.
Parameters
name- The name of the DAG to retrieve.
Options
:limit- Required. The maximum number of runs to preload.:offset- Required. The number of runs to skip before starting to preload.:status- Optional. Filters preloaded runs by status when present.
Returns
Returns the %Dag{} struct with its :runs association preloaded according
to the given pagination options. Raises Ecto.NoResultsError if no DAG
with the given name exists. Raises KeyError if :limit or :offset is
missing from opts.
Gets a DAG by name with its most recent runs preloaded.
Gets a DAG with its runs preloaded.
Gets a DAG with its runs and tasks preloaded, with pagination for runs.
Tasks are loaded with only the fields required by the run-history grid. Use the task or run detail functions when payload fields are needed.
Gets the requested DAGs with their most recent runs preloaded.
Runs are ordered from oldest to newest so they can be displayed as a chronological history. A lateral join limits the runs per DAG while keeping the operation to one database query.
Gets a single log.
Raises Ecto.NoResultsError if the Log does not exist.
Gets logs for a task, optionally filtered by level.
Logs are ordered by their insertion timestamp in ascending order.
Gets a single run.
Raises Ecto.NoResultsError if the Run does not exist.
Examples
iex> get_run!(123)
%Run{}
iex> get_run!(456)
** (Ecto.NoResultsError)
Gets a single run with its tasks preloaded.
Gets runs for a list of DAG IDs with the given statuses.
Parameters
dag_ids: List of DAG IDs to filter runs by.statuses: List of statuses (atoms) to filter runs by (e.g., [:running, :queued]).
Examples
iex> get_running_runs_by_dag([1, 2, 3], [:running, :retrying])
[%Run{}, ...]
Gets runs by ID that belong to the given DAG.
Gets a single secret.
Raises Ecto.NoResultsError if the Secret does not exist.
Gets a single secret by name.
Gets a single task.
Raises Ecto.NoResultsError if the Task does not exist.
Gets a task by name, run ID, and map index.
Gets a task by name and run ID.
Gets a task by name and run ID, with logs preloaded.
Accepts an optional log_level argument:
- When
log_levelisnil(the default), all logs for the task are preloaded. - When
log_levelis provided, only logs with the matching level are preloaded.
Logs are ordered by their inserted_at timestamp in ascending order.
Gets all task statuses by name and run ID.
Gets a task with its logs preloaded.
Gets all task instances by name and run ID.
Lists all DAGs.
Lists all secrets.
Updates a resumed waiting task's params, wait state, and status in one write.
Toggles the enabled status of a DAG.
Updates a run status.
Updates the status of multiple runs in one database statement.
Updates a secret.
Updates a task attempt count.
Updates a task error.
Updates a task map index and its persisted parameters.
Updates a task's persisted parameters.
Updates a task result.
Updates a task result and error.
Updates a task status.
Updates a task's persisted wait state.