Arc.Pipeline (cratis_arc v0.1.0)

Copy Markdown View Source

Runs commands and queries: authorize, bind, validate, provide, handle, record.

This is what the HTTP host, LiveView, Arc.Test and Arc.execute/3 all call, so a rule is implemented once and holds on every path.

Telemetry events are emitted around each run:

  • [:arc, :command, :start | :stop] with %{command: module, correlation_id: id} (stop adds success?)

  • [:arc, :query, :start | :stop] with %{read_model: module, query: name, correlation_id: id}

Summary

Functions

execute_command(command_module, input, ctx, opts \\ [])

@spec execute_command(module(), map() | struct(), Arc.Context.t(), keyword()) ::
  Arc.CommandResult.t()

Executes a command.

input is a wire map (string keys, camelCase) or an already-built command struct.

Options

  • :validate_only - authorize and validate, but do not provide or handle

execute_query(descriptor, query, args, ctx, opts \\ [])

@spec execute_query(
  Arc.Descriptor.t(),
  Arc.Descriptor.Query.t(),
  map(),
  Arc.Context.t(),
  keyword()
) ::
  Arc.QueryResult.t()

Executes a query.

args is a map of raw argument values keyed by wire name (matched case-insensitively).

Options

  • :page, :page_size - zero-based page and page size, applied to lists
  • :sort_by, :sort_direction - field name (camelCase) and :asc or :desc