Skip to main content

Module join

Module join 

Source
Expand description

Runtime join channels that bind a joined sql step to its block session.

A transacted { datasource } block owns exactly one TransactionSession; every joined sql step inside the block must run on that session rather than auto-commit on a fresh connection. The binding is carried in two task-local cells because the pipeline runs a step on the block’s own task, while the load-compiled step cannot hold a runtime Arc:

  • BLOCK_SESSION holds the BlockSession a segment installs for its body task: the datasource, the scope id of the enclosing block, and the session trait object;
  • JOIN_SCOPE holds the scope id baked into a joined sql step at load time.

A joined sql step reads both cells, compares its baked JoinScope with the block’s scope id, and only then joins. Scope membership is lexical, so a mismatch is a hard error rather than a silent join into another block’s transaction.

The cells are task-local on purpose: sibling branches of a split would otherwise observe the same session, which the port forbids (at most one concurrent join per session). Nothing here knows about sqlx or the SQL value model; the session stays a TransactionSession trait object that the sql component downcasts to its concrete type.

Structs§

BlockSession
The datasource, scope id, and session of one running transacted block.
JoinScope
Block scope id, baked per joined sql step and compared at join time.

Statics§

BLOCK_SESSION
Block session installed by the enclosing transacted segment.
JOIN_SCOPE
Join scope id baked into the current sql step at load time.

Functions§

current_block_session
The BlockSession installed for the current task, if any.