TxIndexer

interface TxIndexer

Per-tx entry point for external sources. The source provides tx metadata + a writer that populates the OpenTx and returns a TxResult indicating success or failure (with optional userMetadata — the source can decide metadata after writing, not before).

executeTx and submitTx own the full lifecycle: smoothing, opening the OpenTx, running the writer, adding the xt/txs row, publishing the resulting tx, and closing the OpenTx. They differ only in whether the caller waits for the result.

Types

Link copied to clipboard
sealed interface TxResult

The outcome a writer returns: commit or abort, plus optional userMetadata recorded on the xt/txs table.

Functions

Link copied to clipboard
abstract suspend fun executeTx(externalSourceToken: ExternalSourceToken?, systemTime: Instant? = null, writer: suspend (OpenTx) -> TxIndexer.TxResult): TransactionResult

Indexes one external-source transaction: opens an OpenTx, runs writer to populate it, then commits or aborts per the returned TxResult. Returns only once the tx is durably replicated.

Link copied to clipboard
abstract suspend fun submitTx(externalSourceToken: ExternalSourceToken?, systemTime: Instant? = null, writer: suspend (OpenTx) -> TxIndexer.TxResult): Deferred<TransactionResult>

Like executeTx, but hands the transaction off and returns a durability handle without waiting on it — for a high-volume source that keeps submitting while the indexer works through the backlog, acknowledging progress out of band once transactions become durable (e.g. the Postgres source advancing its replication-slot LSN).