Documentation
¶
Overview ¶
Package postgres stores independent scoped logs in a host-owned PostgreSQL schema. Append and SQL source triggers queue facts in the mutation transaction; a deferred trigger assigns commit-safe positions after locking all its scopes and notifies NotifyChannel(schema) with "<source> <scope>" for each, delivered at commit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Migrate ¶
Migrate installs the shared tables/functions once. The host owns and creates the schema. Run before accepting mutations, using a connection allowed DDL.
func MigrationSQL ¶
MigrationSQL returns an immutable version of the shared schema for inclusion in a product's transactional SQL migration. Keep the returned SQL verbatim in a generated segment and verify it against this function in a contract test. Products may add their own FK/cascade constraints after this segment. This lets a single product migration install the engine, copy retained history and switch its SQL capture atomically. Version 1 installs the engine; version 2, applied after it, makes its flush notify NotifyChannel.
func NewID ¶
func NewID() string
NewID returns an opaque ID suitable for an event without a product-owned ID.
func NotifyChannel ¶ added in v1.20.0
NotifyChannel is where a schema's log says, at commit, that a stream moved: the payload is "<source> <scope>". A consumer LISTENs and reads its stream when it hears it, instead of reading on a clock. Nothing replays a notification sent while no one listened, so a consumer reads once after each (re)LISTEN.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AppendTx ¶
AppendTx queues a fact in the caller's mutation transaction. The log namespace and scope come from this authorized store. Event.Source is product-owned provenance. ID must be stable on retries; an identical retained fact is a no-op; a retained ID with different content fails the transaction rather than overwriting history. Products must never reuse an ID for a different fact, including after pruning. Direct SQL source triggers may insert these same fields into eventlog_pending. Do not force its deferred constraint to immediate or change transaction_id.
func (*Store) EnsureScope ¶
EnsureScope creates a stable empty stream before its first read. It is idempotent; hosts normally call it when creating their tenant/merchant/app.