Framework.Transaction (Framework v0.5.0)

View Source

Transaction DSL Implementation.

Provides the single authoring surface for application logic where authors describe what to READ, GUARD, COMPUTE, WRITE, return results, navigate, and trigger effects.

The runtime compiles plan graphs into a single Ecto.Multi transaction with enforced isolation (READ COMMITTED) and natural-key upserts.

From transaction-dsl.md:

  • No I/O in plan/2 functions - get/2 and list/2 produce READ nodes
  • DB resolution occurs only inside the single commit transaction
  • Node kinds: READ · GUARD · COMPUTE · WRITE · RESULT · EFFECT · NAV
  • Allowed branches: predicates over input, ctx, and READ node fields
  • Guards must be pure and deterministic
  • Translation helpers t/3 and tn/5 are pure - read from ctx.locale

Summary

Functions

Compile a plan graph into a single Ecto.Multi transaction.

Define an operation with a plan function.

Functions

compile_to_multi(plan_graph, ctx \\ %{})

Compile a plan graph into a single Ecto.Multi transaction.

This is the core implementation that transforms the pure plan data structure into an Ecto.Multi with enforced isolation and natural-key upserts.

operation(name, list)

(macro)

Define an operation with a plan function.

The plan function must be pure and return a plan graph data structure. No I/O is allowed in plan functions.