Blitz (blitz v0.4.1)

Copy Markdown View Source

Lightweight parallel command execution for Elixir tooling.

Blitz runs isolated OS commands with bounded concurrency and prefixes streamed output with a stable command id so parallel logs remain readable.

For config-driven Mix monorepos, see Blitz.MixWorkspace.

Summary

Functions

Builds a %Blitz.Command{} from a keyword list or map.

Runs commands in parallel and returns their results.

Runs commands in parallel and raises if any command fails.

Runs staged commands as per-id pipelines without barriers between stages.

Runs staged commands as per-id pipelines and raises if any command fails.

Types

command()

@type command() :: Blitz.Command.t()

run_option()

@type run_option() ::
  {:announce?, boolean()}
  | {:max_concurrency, pos_integer()}
  | {:prefix_output?, boolean()}
  | {:timeout, timeout()}

stage()

@type stage() :: %{
  optional(atom()) => term(),
  commands: [command()],
  max_concurrency: pos_integer()
}

stage_option()

@type stage_option() ::
  {:announce?, boolean()} | {:prefix_output?, boolean()} | {:timeout, timeout()}

Functions

command(attributes)

@spec command(keyword() | map()) :: Blitz.Command.t()

Builds a %Blitz.Command{} from a keyword list or map.

run(commands, opts \\ [])

@spec run([command()], [run_option()]) ::
  {:ok, [Blitz.Result.t()]} | {:error, Blitz.Error.t()}

Runs commands in parallel and returns their results.

run!(commands, opts \\ [])

@spec run!([command()], [run_option()]) :: [Blitz.Result.t()]

Runs commands in parallel and raises if any command fails.

run_stages(stages, opts \\ [])

@spec run_stages([stage()], [stage_option()]) ::
  {:ok, [[Blitz.Result.t()]]} | {:error, Blitz.Error.t(), [[Blitz.Result.t()]]}

Runs staged commands as per-id pipelines without barriers between stages.

Each stage bounds its own commands with its :max_concurrency, and total in-flight commands across all stages never exceed the largest stage :max_concurrency. A command in a later stage starts as soon as every same-id command in earlier stages has succeeded — it does not wait for the rest of the earlier stage. A failed command permanently blocks same-id commands in later stages, and no new commands launch after the first failure; in-flight commands finish and are reported.

Returns {:ok, results_per_stage} when every launched command succeeds, or {:error, error, results_per_stage} where results_per_stage contains only the commands that actually ran.

run_stages!(stages, opts \\ [])

@spec run_stages!([stage()], [stage_option()]) :: [[Blitz.Result.t()]]

Runs staged commands as per-id pipelines and raises if any command fails.