defmodule Hello do @moduledoc false # `schedule` and `on_finished_callback` are optional. use Gust.DSL, schedule: "* * * * *", on_finished_callback: :notify_something # Gust logs are stored and displayed through GustWeb via Logger. require Logger # Gust.Flows is used to query Dag, Run, and Task. alias Gust.Flows def notify_something(status, run) do dag = Flows.get_dag!(run.dag_id) message = "DAG: #{dag.name}; completed with status: #{status}" Logger.info(message) end def skip_first_task?(%{run_id: run_id}) do run = Flows.get_run!(run_id) Map.get(run.params, "skip_first_task", false) end task :first_task, downstream: [:second_task], save: true, skip_if: :skip_first_task? do greetings = "Hi from first_task" Logger.info(greetings) greetings = ["Hello!", "Olá!", "¡Hola!", "Bonjour!"] # You can get secrets created on the Web UI secret = Flows.get_secret_by_name("SUPER_SECRET") if secret do Logger.warning("I know your secret: #{secret.value}") end # The return value must be a map or a list when `save` is true. greetings end task :second_task, downstream: [:final_task], ctx: %{params: params}, map_over: :first_task, save: true do message = "#{params["item"]} World!" Logger.warning(message) %{greeting: message} end task :final_task, ctx: %{run_id: run_id} do # Getting tasks results second_tasks = Flows.get_tasks_by_name("second_task", run_id) Enum.each(second_tasks, fn task -> Logger.warning(inspect(task.result)) end) end end