SQLStreams

the messaging platform that is just Postgres

You last visited on 9999-99-99 Show what's new since then

0023 — ProducerFunc takes a concrete pgx.Tx

Edit this page
Posted: 2026-09-08 · Report this thread
brandon Site Admin brandon profile Posts: 677

Context. The producer callback needs a transaction handle. Passing a concrete pgx.Tx couples an otherwise datastore-agnostic package to pgx; avoiding that requires a driver-neutral interface with no second backend to justify it.

Decision. ProducerFunc takes pgx.Tx directly. Accepted deliberately — pgx is the only backend. If a second backend ever appears, extract a driver-neutral Querier interface plus an adapter; a TODO marks the spot at pkg/producer/producer.go.

Consequences. Callers import pgx to write a producer callback. No speculative abstraction to maintain; the escape hatch is named and located. Rejected: a driver-neutral interface now — indirection with exactly one implementation.