Documentation
¶
Index ¶
- Constants
- Variables
- func BackupWithAdapter[T any](ctx context.Context, db *sql.DB, w io.Writer, ...) error
- func BackupWithAdapterCopy[T any](ctx context.Context, db *sql.DB, w io.Writer, ...) (retErr error)
- func ClearTableSchemaCache(replicationID string)
- func ConnectHandler(interceptors ...connect.ServerInterceptor) (path string, handler http.Handler)
- func ContextLocalDB(ctx context.Context, useLocalDB bool) context.Context
- func CrossShardQuery(ctx context.Context, stmt *Statement, args []driver.NamedValue, ...) (driver.Rows, error)
- func DefaultLWWTieBreaker(incomingNode, localNode string) bool
- func ExtractRawConn[T any](conn *sql.Conn) (T, error)
- func HistoryTableDeclaration(tableName string) string
- func LatestSnapshot(ctx context.Context, dsn string, options ...Option) (sequence uint64, reader io.ReadCloser, err error)
- func ListDSN() []string
- func ListReplicationIDs() []string
- func LocalDB(ctx context.Context) bool
- func MountConnect(mux connecthttp.ServeMux, interceptors []connect.ServerInterceptor, ...)
- func NewConnectServer(interceptors ...connect.ServerInterceptor) *connect.Server
- func Shutdown()
- func UndoFunc(connector *Connector, filter haconnect.UndoFilter) func(int64) string
- type BackupFn
- type CDCPublisher
- type Change
- type ChangeFilterFunc
- type ChangeSet
- func (cs *ChangeSet) AddChange(change Change)
- func (cs *ChangeSet) AfterCommit(conn *sql.Conn, err error) error
- func (cs *ChangeSet) Apply(ctx context.Context, db *sql.DB) (err error)
- func (cs *ChangeSet) Clear()
- func (cs *ChangeSet) DebeziumData() []DebeziumData
- func (cs *ChangeSet) Prepare(ctx context.Context, db *sql.DB) (conn *haconnect.ConnHooksEnabler, tx *sql.Tx, err error)
- func (cs *ChangeSet) Send(ctx context.Context, pub Publisher) error
- func (cs *ChangeSet) SetConnProvider(connProvider ConnHooksProvider)
- func (cs *ChangeSet) SetInterceptor(interceptor ChangeSetInterceptor)
- func (cs *ChangeSet) SetStrategy(t sqlStrategy)
- func (cs *ChangeSet) UndoLocal(db *sql.DB) error
- type ChangeSetInterceptor
- type ChangeSetInterceptorFuncs
- type ChangeSetSerializer
- type ColumnLWWConflictHandler
- type ColumnLWWInterceptor
- type ColumnLWWOption
- func WithColumnLWWAtomicTransaction(atomic bool) ColumnLWWOption
- func WithColumnLWWIgnoreTables(tables ...string) ColumnLWWOption
- func WithColumnLWWOnConflict(fn ColumnLWWConflictHandler) ColumnLWWOption
- func WithColumnLWWStrictMissingColumn(strict bool) ColumnLWWOption
- func WithColumnLWWTables(tables ...string) ColumnLWWOption
- func WithColumnLWWTieBreaker(fn LWWTieBreaker) ColumnLWWOption
- func WithNodeTieBreakerColumn(column string) ColumnLWWOption
- func WithTableVersionColumn(table, column string) ColumnLWWOption
- type CompositeInterceptor
- type CompositePublisher
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)
- func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (tx driver.Tx, retErr error)
- func (c *Conn) CheckNamedValue(nv *driver.NamedValue) error
- func (c *Conn) Close() error
- func (c *Conn) Context() context.Context
- func (c *Conn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (result driver.Result, retErr error)
- func (c *Conn) IsValid() bool
- func (c *Conn) Mutex() *sync.Mutex
- func (c *Conn) Ping(ctx context.Context) error
- func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (result driver.Rows, retErr error)
- func (c *Conn) ResetSession(ctx context.Context) error
- type ConnHooksFactory
- type ConnHooksProvider
- type Connector
- func (c *Connector) Backup(ctx context.Context, writer io.Writer) error
- func (c *Connector) CDCPublisher() CDCPublisher
- func (c *Connector) Close()
- func (c *Connector) Connect(ctx context.Context) (driver.Conn, error)
- func (c *Connector) ConsistentReader(timeout time.Duration, methods ...string) func(http.Handler) http.Handler
- func (c *Connector) ConsistentReaderFunc(h http.HandlerFunc, timeout time.Duration, methods ...string) http.HandlerFunc
- func (c *Connector) ContiguousSeq() uint64
- func (c *Connector) DB() *sql.DB
- func (c *Connector) DeliveredInfo(ctx context.Context, name string) (any, error)
- func (c *Connector) DisableDDLSync() bool
- func (c *Connector) DisableHooks(conn *sql.Conn) error
- func (c *Connector) Driver() driver.Driver
- func (c *Connector) EnableHooks(conn *sql.Conn) error
- func (c *Connector) ForwardToLeader(timeout time.Duration, methods ...string) func(http.Handler) http.Handler
- func (c *Connector) ForwardToLeaderFunc(h http.HandlerFunc, timeout time.Duration, methods ...string) http.HandlerFunc
- func (c *Connector) GrpcInsecure() bool
- func (c *Connector) GrpcTimeout() time.Duration
- func (c *Connector) GrpcToken() string
- func (c *Connector) HealthHandler() http.Handler
- func (c *Connector) HistoryBySeq(ctx context.Context, startSeq uint64) ([]haconnect.HistoryItem, error)
- func (c *Connector) HistoryByTime(ctx context.Context, duration time.Duration) ([]haconnect.HistoryItem, error)
- func (c *Connector) LatestSeq() uint64
- func (c *Connector) LatestSnapshot(ctx context.Context) (uint64, io.ReadCloser, error)
- func (c *Connector) LeaderProvider() LeaderProvider
- func (c *Connector) Mutex() *sync.Mutex
- func (c *Connector) NodeName() string
- func (c *Connector) ObservabilityHandler() http.Handler
- func (c *Connector) ProxiedDB() *sql.DB
- func (c *Connector) ProxiedPositionProvider() ProxiedPositionProvider
- func (c *Connector) PruneMetadata(ctx context.Context, olderThan time.Duration) error
- func (c *Connector) PubSeq() uint64
- func (c *Connector) Publisher() Publisher
- func (c *Connector) QueryRouter() *regexp.Regexp
- func (c *Connector) ReadinessHandler() http.Handler
- func (c *Connector) RemoveConsumer(ctx context.Context, name string) error
- func (c *Connector) ReplicationID() string
- func (c *Connector) ResponseWriter(w http.ResponseWriter) http.ResponseWriter
- func (c *Connector) SetProxiedDB(db *sql.DB)
- func (c *Connector) SetProxiedPositionProvider(provider ProxiedPositionProvider)
- func (c *Connector) Snapshotter() DBSnapshotter
- func (c *Connector) Start(db *sql.DB) error
- func (c *Connector) Subscriber() Subscriber
- func (c *Connector) TakeSnapshot(ctx context.Context) (sequence uint64, err error)
- func (c *Connector) UndoBySeq(ctx context.Context, startSeq uint64, filterType haconnect.UndoFilter, ...) error
- func (c *Connector) UndoByTime(ctx context.Context, duration time.Duration, filterType haconnect.UndoFilter, ...) error
- type DBPublisher
- type DBSnapshotter
- type DBSubscriber
- func (s *DBSubscriber) DB() *sql.DB
- func (s *DBSubscriber) DeliveredInfo(ctx context.Context, name string) (any, error)
- func (s *DBSubscriber) HistoryBySeq(ctx context.Context, startSeq uint64) ([]haconnect.HistoryItem, error)
- func (s *DBSubscriber) HistoryByTime(ctx context.Context, duration time.Duration) ([]haconnect.HistoryItem, error)
- func (s *DBSubscriber) LatestSeq() uint64
- func (s *DBSubscriber) RemoveConsumer(ctx context.Context, name string) error
- func (s *DBSubscriber) SeqNotifyCh() <-chan struct{}
- func (s *DBSubscriber) SetDB(db *sql.DB)
- func (s *DBSubscriber) Start() error
- func (s *DBSubscriber) UndoBySeq(ctx context.Context, startSeq uint64, filter haconnect.UndoFilter, ...) error
- func (s *DBSubscriber) UndoByTime(ctx context.Context, duration time.Duration, filterType haconnect.UndoFilter, ...) error
- type DBSubscriberConfig
- type DebeziumData
- type DebeziumPayload
- type DebeziumSource
- type DebeziumTransaction
- type DynamicLeader
- type EmbeddedNatsConfig
- type FilterInterceptor
- func NewAllowOperationsInterceptor(operations ...string) *FilterInterceptor
- func NewAllowTablesInterceptor(tables ...string) *FilterInterceptor
- func NewFilterInterceptor(keep ChangeFilterFunc) *FilterInterceptor
- func NewIgnoreOperationsInterceptor(operations ...string) *FilterInterceptor
- func NewIgnoreTablesInterceptor(tables ...string) *FilterInterceptor
- type HistoryCursor
- type HookCallbacks
- type JSONPublisher
- type LWWConflictHandler
- type LWWOption
- func WithLWWAtomicTransaction(atomic bool) LWWOption
- func WithLWWIgnoreTables(tables ...string) LWWOption
- func WithLWWOnConflict(fn LWWConflictHandler) LWWOption
- func WithLWWRetentionTTL(ttl time.Duration) LWWOption
- func WithLWWTableName(name string) LWWOption
- func WithLWWTables(tables ...string) LWWOption
- func WithLWWTieBreaker(fn LWWTieBreaker) LWWOption
- type LWWTieBreaker
- type LastWriterWinsInterceptor
- func (i *LastWriterWinsInterceptor) AfterApply(cs *ChangeSet, conn *sql.Conn, applyErr error) error
- func (i *LastWriterWinsInterceptor) BeforeApply(cs *ChangeSet, conn *sql.Conn) (bool, error)
- func (i *LastWriterWinsInterceptor) OnLocalChangeSet(cs *ChangeSet)
- func (i *LastWriterWinsInterceptor) PruneBefore(ctx context.Context, db *sql.DB, cutoff time.Time) (int64, error)
- type LeaderProvider
- type LocalChangeSetObserver
- type NATSPublisher
- type NATSSnapshotter
- func (s *NATSSnapshotter) Close() error
- func (s *NATSSnapshotter) DB() *sql.DB
- func (s *NATSSnapshotter) LatestSnapshot(ctx context.Context) (uint64, io.ReadCloser, error)
- func (s *NATSSnapshotter) LatestSnapshotSequence(ctx context.Context) (uint64, error)
- func (s *NATSSnapshotter) LatestSnapshotTime() time.Time
- func (s *NATSSnapshotter) SetDB(db *sql.DB)
- func (s *NATSSnapshotter) Start()
- func (s *NATSSnapshotter) TakeSnapshot(ctx context.Context) (sequence uint64, err error)
- type NATSSubscriber
- func (s *NATSSubscriber) Close() error
- func (s *NATSSubscriber) DB() *sql.DB
- func (s *NATSSubscriber) DeliveredInfo(ctx context.Context, name string) (any, error)
- func (s *NATSSubscriber) HistoryBySeq(ctx context.Context, startSeq uint64) ([]haconnect.HistoryItem, error)
- func (s *NATSSubscriber) HistoryByTime(ctx context.Context, duration time.Duration) ([]haconnect.HistoryItem, error)
- func (s *NATSSubscriber) LatestSeq() uint64
- func (s *NATSSubscriber) RemoveConsumer(ctx context.Context, name string) error
- func (s *NATSSubscriber) SeqNotifyCh() <-chan struct{}
- func (s *NATSSubscriber) SetDB(db *sql.DB)
- func (s *NATSSubscriber) Start() error
- func (s *NATSSubscriber) UndoBySeq(ctx context.Context, startSeq uint64, filterType haconnect.UndoFilter, ...) error
- func (s *NATSSubscriber) UndoByTime(ctx context.Context, duration time.Duration, filterType haconnect.UndoFilter, ...) error
- type NATSSubscriberConfig
- type NoopInterceptor
- type NoopPublisher
- type NoopSnapshotter
- func (s *NoopSnapshotter) DB() *sql.DB
- func (s *NoopSnapshotter) LatestSnapshot(ctx context.Context) (uint64, io.ReadCloser, error)
- func (s *NoopSnapshotter) LatestSnapshotTime() time.Time
- func (s *NoopSnapshotter) SetDB(_ *sql.DB)
- func (s *NoopSnapshotter) Start()
- func (s *NoopSnapshotter) TakeSnapshot(ctx context.Context) (sequence uint64, err error)
- type NoopSubscriber
- func (s *NoopSubscriber) DB() *sql.DB
- func (*NoopSubscriber) DeliveredInfo(ctx context.Context, name string) (any, error)
- func (*NoopSubscriber) HistoryBySeq(ctx context.Context, startSeq uint64) ([]haconnect.HistoryItem, error)
- func (*NoopSubscriber) HistoryByTime(ctx context.Context, duration time.Duration) ([]haconnect.HistoryItem, error)
- func (s *NoopSubscriber) LatestSeq() uint64
- func (*NoopSubscriber) RemoveConsumer(ctx context.Context, name string) error
- func (s *NoopSubscriber) SetDB(db *sql.DB)
- func (s *NoopSubscriber) Start() error
- func (*NoopSubscriber) UndoBySeq(ctx context.Context, startSeq uint64, filter haconnect.UndoFilter, ...) error
- func (*NoopSubscriber) UndoByTime(ctx context.Context, duration time.Duration, filter haconnect.UndoFilter, ...) error
- type ObservabilityStatus
- type Option
- func NameToOptions(name string, baseDriver string) (string, []Option, error)
- func WithAsyncPublisher() Option
- func WithAutoStart(enabled bool) Option
- func WithBackupFn(fn BackupFn) Option
- func WithCDCPublisher(p CDCPublisher) Option
- func WithChangeSetInterceptor(interceptor ChangeSetInterceptor) Option
- func WithClusterSize(size int) Option
- func WithDBSnapshotter(snap DBSnapshotter) Option
- func WithDeliverPolicy(deliverPolicy string) Option
- func WithDisableDDLSync() Option
- func WithEmbeddedNatsConfig(cfg *EmbeddedNatsConfig) Option
- func WithExtensions(extensions ...string) Option
- func WithForcePublishBeforeStart(enabled bool) Option
- func WithGrpcInsecure(insecure bool) Option
- func WithGrpcPort(port int) Option
- func WithGrpcTimeout(timeout time.Duration) Option
- func WithGrpcToken(token string) Option
- func WithLeaderElectionLocalTarget(localEndpoint string) Option
- func WithLeaderProvider(p LeaderProvider) Option
- func WithMetadataRetention(ttl time.Duration) Option
- func WithName(name string) Option
- func WithNatsOptions(options ...nats.Option) Option
- func WithOpenTelemetry(meterProvider metric.MeterProvider, tracerProvider trace.TracerProvider) Option
- func WithProxiedDB(db *sql.DB) Option
- func WithProxiedPositionProvider(provider ProxiedPositionProvider) Option
- func WithPublisherTimeout(timeout time.Duration) Option
- func WithQueryRouter(re *regexp.Regexp) Option
- func WithReplicas(replicas int) Option
- func WithReplicationID(id string) Option
- func WithReplicationPublisher(pub Publisher) Option
- func WithReplicationStream(stream string) Option
- func WithReplicationSubscriber(sub Subscriber) Option
- func WithReplicationURL(url string) Option
- func WithRowIdentify(i RowIdentify) Option
- func WithSnapshotInterval(interval time.Duration) Option
- func WithStreamMaxAge(maxAge time.Duration) Option
- func WithWaitFor(ch chan struct{}) Option
- type OutboxPublisher
- func (p *OutboxPublisher) BindLocalDB(db *sql.DB) error
- func (p *OutboxPublisher) Close() error
- func (p *OutboxPublisher) PrepareTwoPhaseCommit(_ context.Context, cs *ChangeSet) (PreparedTwoPhaseCommit, error)
- func (p *OutboxPublisher) Publish(ctx context.Context, cs *ChangeSet) error
- func (p *OutboxPublisher) SeqNotifyCh() <-chan struct{}
- func (p *OutboxPublisher) Sequence() uint64
- func (p *OutboxPublisher) SequenceRange() (uint64, uint64)
- type PreparedTwoPhaseCommit
- type ProxiedPositionProvider
- type ProxiedQuerierExecer
- type Publisher
- type RowIdentify
- type SQLiteConn
- type SQLiteHooksAdapter
- type SequenceNotifier
- type SequenceProvider
- type Statement
- func (s *Statement) AggregateFunctions() map[int]*sql.Call
- func (s *Statement) Begin() bool
- func (s *Statement) Columns() []string
- func (s *Statement) Commit() bool
- func (s *Statement) DDL() bool
- func (s *Statement) HasDistinct() bool
- func (s *Statement) HasReturning() bool
- func (s *Statement) IsCreateTable() bool
- func (s *Statement) IsDelete() bool
- func (s *Statement) IsExplain() bool
- func (s *Statement) IsInsert() bool
- func (s *Statement) IsSelect() bool
- func (s *Statement) IsUpdate() bool
- func (s *Statement) Limit() int
- func (s *Statement) ModifiesDatabase() bool
- func (s *Statement) OrderBy() []string
- func (s *Statement) Parameters() []string
- func (s *Statement) RewriteQueryToAggregate() (query string, aggregateFunctions map[int]*sql.Call, newColumns map[int]int, ...)
- func (s *Statement) Rollback() bool
- func (s *Statement) Source() string
- func (s *Statement) SourceWithIfExists() string
- func (s *Statement) Type() string
- func (s *Statement) Visit(n sql.Node) (w sql.Visitor, node sql.Node, err error)
- func (s *Statement) VisitEnd(n sql.Node) (sql.Node, error)
- type StaticLeader
- type Subscriber
- type TwoPhaseCommitDecisionWriter
- type TwoPhaseCommitPreparer
- type TwoPhaseCommitPublisher
- func (p *TwoPhaseCommitPublisher) BindLocalDB(db *sql.DB) error
- func (p *TwoPhaseCommitPublisher) Close() error
- func (p *TwoPhaseCommitPublisher) PrepareTwoPhaseCommit(ctx context.Context, cs *ChangeSet) (PreparedTwoPhaseCommit, error)
- func (p *TwoPhaseCommitPublisher) Publish(ctx context.Context, cs *ChangeSet) (err error)
- func (p *TwoPhaseCommitPublisher) RecoverTwoPhaseCommits(ctx context.Context) error
- func (p *TwoPhaseCommitPublisher) Sequence() uint64
- type TxSeqTracker
- type TxSeqTrackerProvider
- type WriterPublisher
Constants ¶
const ( HealthPath = "/healthz" ReadinessPath = "/readyz" )
const ( TypeExplain = "EXPLAIN" TypeSelect = "SELECT" TypeInsert = "INSERT" TypeUpdate = "UPDATE" TypeDelete = "DELETE" TypeCreateTable = "CREATE TABLE" TypeCreateIndex = "CREATE INDEX" TypeCreateView = "CREATE VIEW" TypeCreateTrigger = "CREATE TRIGGER" TypeCreateVirtualTable = "CREATE VIRTUAL TABLE" TypeAlterTable = "ALTER TABLE" TypeVacuum = "VACUUM" TypeDrop = "DROP" TypeAnalyze = "ANALYZE" TypeBegin = "BEGIN" TypeCommit = "COMMIT" TypeRollback = "ROLLBACK" TypeSavepoint = "SAVEPOINT" TypeRelease = "RELEASE" TypePragma = "PRAGMA" TypeOther = "OTHER" )
const DefaultLWWTableName = "ha_lww_versions"
DefaultLWWTableName is the default local metadata table used by LastWriterWinsInterceptor to persist per-row version timestamps and tombstones.
const DefaultStream = "ha_replication"
const OutboxTable = "ha_outbox"
OutboxTable stores local changeset for async publishing.
const (
TXCookieName = "_txseq"
)
const TwoPhaseCommitDecisionTable = "ha_2pc_decisions"
TwoPhaseCommitDecisionTable stores local commit decisions for crash recovery.
Variables ¶
var (
ErrInvalidSQL = fmt.Errorf("invalid SQL")
)
var ErrSnapshotterNotConfigured = errors.New("snapshotter not configured")
var ErrTimedOut = errors.New("Timed out")
var ErrTwoPhaseCommitPending = errors.New("two-phase commit is committed locally and pending remote recovery")
ErrTwoPhaseCommitPending marks a transaction committed locally but awaiting remote recovery.
Functions ¶
func BackupWithAdapter ¶ added in v0.16.0
func BackupWithAdapterCopy ¶ added in v0.18.2
func ClearTableSchemaCache ¶ added in v0.16.0
func ClearTableSchemaCache(replicationID string)
func ConnectHandler ¶ added in v0.8.0
func ConnectHandler(interceptors ...connect.ServerInterceptor) (path string, handler http.Handler)
func ContextLocalDB ¶ added in v0.11.4
func CrossShardQuery ¶ added in v0.5.8
func DefaultLWWTieBreaker ¶ added in v0.17.0
DefaultLWWTieBreaker deterministically breaks timestamp ties by comparing node names lexicographically. For identical node names (e.g. idempotent replay or consecutive writes in the same nanosecond), incoming wins.
func HistoryTableDeclaration ¶ added in v0.16.0
func LatestSnapshot ¶ added in v0.0.4
func ListReplicationIDs ¶ added in v0.4.5
func ListReplicationIDs() []string
func MountConnect ¶ added in v0.18.0
func MountConnect(mux connecthttp.ServeMux, interceptors []connect.ServerInterceptor, opts ...connecthttp.Option)
func NewConnectServer ¶ added in v0.18.0
func NewConnectServer(interceptors ...connect.ServerInterceptor) *connect.Server
Types ¶
type CDCPublisher ¶
type CDCPublisher interface {
Publish(data []DebeziumData) error
}
type Change ¶
type Change struct {
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
Columns []string `json:"columns,omitempty"`
PKColumns []string `json:"pk_columns,omitempty"`
Operation string `json:"operation"` // "INSERT", "UPDATE", "DELETE", "SQL", "CUSTOM"
OldRowID int64 `json:"old_rowid,omitempty"`
NewRowID int64 `json:"new_rowid,omitempty"`
OldValues []any `json:"old_values,omitempty"`
NewValues []any `json:"new_values,omitempty"`
Command string `json:"command,omitempty"`
Args []any `json:"args,omitempty"`
TsNs int64 `json:"ts_ns,omitempty"`
}
func (Change) PKColumnsNames ¶ added in v0.2.0
func (Change) PKNewValues ¶ added in v0.2.1
func (Change) PKOldValues ¶ added in v0.2.0
type ChangeFilterFunc ¶ added in v0.17.0
ChangeFilterFunc decides whether an individual Change within a ChangeSet should be applied.
type ChangeSet ¶
type ChangeSet struct {
Node string `json:"node"`
ProcessID int64 `json:"process_id"`
Filename string `json:"filename"`
Changes []Change `json:"changes"`
TraceContext map[string]string `json:"trace_context,omitempty"`
Timestamp int64 `json:"timestamp_ns"`
TransactionID string `json:"transaction_id,omitempty"`
Subject string `json:"-"`
StreamSeq uint64 `json:"-"`
// contains filtered or unexported fields
}
func NewChangeSet ¶
func (*ChangeSet) AfterCommit ¶ added in v0.12.2
func (*ChangeSet) DebeziumData ¶ added in v0.3.0
func (cs *ChangeSet) DebeziumData() []DebeziumData
func (*ChangeSet) SetConnProvider ¶ added in v0.0.10
func (cs *ChangeSet) SetConnProvider(connProvider ConnHooksProvider)
func (*ChangeSet) SetInterceptor ¶ added in v0.0.6
func (cs *ChangeSet) SetInterceptor(interceptor ChangeSetInterceptor)
func (*ChangeSet) SetStrategy ¶ added in v0.10.5
func (cs *ChangeSet) SetStrategy(t sqlStrategy)
type ChangeSetInterceptor ¶ added in v0.0.6
type ChangeSetInterceptorFuncs ¶ added in v0.17.0
type ChangeSetInterceptorFuncs struct {
BeforeApplyFn func(cs *ChangeSet, conn *sql.Conn) (skip bool, err error)
AfterApplyFn func(cs *ChangeSet, conn *sql.Conn, applyErr error) error
}
ChangeSetInterceptorFuncs adapts plain functions to the ChangeSetInterceptor interface.
func (ChangeSetInterceptorFuncs) AfterApply ¶ added in v0.17.0
func (ChangeSetInterceptorFuncs) BeforeApply ¶ added in v0.17.0
type ChangeSetSerializer ¶ added in v0.0.6
type ColumnLWWConflictHandler ¶ added in v0.17.0
ColumnLWWConflictHandler is invoked whenever an incoming Change loses column-based LWW resolution.
type ColumnLWWInterceptor ¶ added in v0.17.0
type ColumnLWWInterceptor struct {
NoopInterceptor
// contains filtered or unexported fields
}
ColumnLWWInterceptor implements Last-Writer-Wins / monotonic-version conflict resolution by comparing a column on the target table itself (such as "updated_at", "version", or an HLC string) against the current row stored in the local database.
Supported column types include integers, floats, time.Time, RFC3339 / SQLite datetime strings, and lexicographically ordered strings (such as ISO-8601 UTC or HLCs). For DELETE changes, the delete applies only if the local row version has not advanced past the version observed in Change.OldValues, preventing concurrent updates from being lost while maintaining convergence across nodes.
func NewColumnLWWInterceptor ¶ added in v0.17.0
func NewColumnLWWInterceptor(column string, opts ...ColumnLWWOption) *ColumnLWWInterceptor
NewColumnLWWInterceptor creates a ColumnLWWInterceptor using column as the default version/timestamp column name (defaults to "updated_at" if empty).
func (*ColumnLWWInterceptor) BeforeApply ¶ added in v0.17.0
type ColumnLWWOption ¶ added in v0.17.0
type ColumnLWWOption func(*ColumnLWWInterceptor)
ColumnLWWOption configures a ColumnLWWInterceptor.
func WithColumnLWWAtomicTransaction ¶ added in v0.17.0
func WithColumnLWWAtomicTransaction(atomic bool) ColumnLWWOption
WithColumnLWWAtomicTransaction controls whether a conflict on any single row skips the entire ChangeSet transaction (true) or only drops the stale row Changes (false, default).
func WithColumnLWWIgnoreTables ¶ added in v0.17.0
func WithColumnLWWIgnoreTables(tables ...string) ColumnLWWOption
WithColumnLWWIgnoreTables excludes the given tables from column-based LWW conflict resolution.
func WithColumnLWWOnConflict ¶ added in v0.17.0
func WithColumnLWWOnConflict(fn ColumnLWWConflictHandler) ColumnLWWOption
WithColumnLWWOnConflict registers a callback invoked whenever an incoming Change loses resolution.
func WithColumnLWWStrictMissingColumn ¶ added in v0.17.0
func WithColumnLWWStrictMissingColumn(strict bool) ColumnLWWOption
WithColumnLWWStrictMissingColumn returns an error in BeforeApply if a managed table does not contain the configured version column (default false: changes pass through).
func WithColumnLWWTables ¶ added in v0.17.0
func WithColumnLWWTables(tables ...string) ColumnLWWOption
WithColumnLWWTables restricts column-based LWW conflict resolution to the given tables.
func WithColumnLWWTieBreaker ¶ added in v0.17.0
func WithColumnLWWTieBreaker(fn LWWTieBreaker) ColumnLWWOption
WithColumnLWWTieBreaker sets the node tie-breaker used together with WithNodeTieBreakerColumn.
func WithNodeTieBreakerColumn ¶ added in v0.17.0
func WithNodeTieBreakerColumn(column string) ColumnLWWOption
WithNodeTieBreakerColumn specifies an optional column storing the writer's node identifier to break ties when two concurrent writes carry the exact same version/timestamp value. When unset, ties are broken deterministically by comparing row column values.
func WithTableVersionColumn ¶ added in v0.17.0
func WithTableVersionColumn(table, column string) ColumnLWWOption
WithTableVersionColumn overrides the version/timestamp column name for a specific table.
type CompositeInterceptor ¶ added in v0.17.0
type CompositeInterceptor struct {
// contains filtered or unexported fields
}
CompositeInterceptor chains multiple ChangeSetInterceptors together. BeforeApply executes interceptors in order and stops early if any interceptor returns skip=true or a non-nil error. AfterApply executes in reverse order for all interceptors whose BeforeApply ran.
func NewCompositeInterceptor ¶ added in v0.17.0
func NewCompositeInterceptor(interceptors ...ChangeSetInterceptor) *CompositeInterceptor
NewCompositeInterceptor creates a CompositeInterceptor from the given interceptors. Nil entries are ignored.
func (*CompositeInterceptor) AfterApply ¶ added in v0.17.0
func (*CompositeInterceptor) BeforeApply ¶ added in v0.17.0
func (*CompositeInterceptor) OnLocalChangeSet ¶ added in v0.17.0
func (c *CompositeInterceptor) OnLocalChangeSet(cs *ChangeSet)
type CompositePublisher ¶ added in v0.12.1
type CompositePublisher struct {
// contains filtered or unexported fields
}
func NewCompositePublisher ¶ added in v0.12.1
func NewCompositePublisher(publishers ...Publisher) *CompositePublisher
func (*CompositePublisher) Close ¶ added in v0.18.0
func (p *CompositePublisher) Close() error
func (*CompositePublisher) Publish ¶ added in v0.12.1
func (p *CompositePublisher) Publish(ctx context.Context, cs *ChangeSet) error
func (*CompositePublisher) Sequence ¶ added in v0.12.1
func (p *CompositePublisher) Sequence() uint64
type Conn ¶
type Conn struct {
SQLiteConn
// contains filtered or unexported fields
}
func (*Conn) CheckNamedValue ¶ added in v0.16.0
func (c *Conn) CheckNamedValue(nv *driver.NamedValue) error
func (*Conn) ExecContext ¶
func (*Conn) QueryContext ¶ added in v0.16.0
type ConnHooksFactory ¶ added in v0.0.10
type ConnHooksFactory func() ConnHooksProvider
type ConnHooksProvider ¶ added in v0.0.10
type ConnHooksProvider interface {
RegisterHooks(driver.Conn, *Connector) (driver.Conn, error)
DisableHooks(*sql.Conn) error
EnableHooks(*sql.Conn) error
}
func NewSQLiteHooksProvider ¶ added in v0.16.0
func NewSQLiteHooksProvider(adapter SQLiteHooksAdapter) ConnHooksProvider
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
func LookupConnector ¶ added in v0.1.0
func LookupConnectorByReplicationID ¶ added in v0.4.5
func NewConnector ¶
func (*Connector) CDCPublisher ¶ added in v0.3.0
func (c *Connector) CDCPublisher() CDCPublisher
func (*Connector) ConsistentReader ¶ added in v0.1.0
func (*Connector) ConsistentReaderFunc ¶ added in v0.1.0
func (c *Connector) ConsistentReaderFunc(h http.HandlerFunc, timeout time.Duration, methods ...string) http.HandlerFunc
func (*Connector) ContiguousSeq ¶ added in v0.16.2
func (*Connector) DeliveredInfo ¶
func (*Connector) DisableDDLSync ¶ added in v0.13.0
func (*Connector) DisableHooks ¶ added in v0.13.5
func (*Connector) EnableHooks ¶ added in v0.13.5
func (*Connector) ForwardToLeader ¶ added in v0.1.0
func (*Connector) ForwardToLeaderFunc ¶ added in v0.1.0
func (c *Connector) ForwardToLeaderFunc(h http.HandlerFunc, timeout time.Duration, methods ...string) http.HandlerFunc
func (*Connector) GrpcInsecure ¶ added in v0.13.0
func (*Connector) GrpcTimeout ¶ added in v0.13.0
func (*Connector) HealthHandler ¶ added in v0.15.0
func (*Connector) HistoryBySeq ¶ added in v0.10.5
func (*Connector) HistoryByTime ¶ added in v0.10.5
func (*Connector) LatestSnapshot ¶
func (*Connector) LeaderProvider ¶ added in v0.1.1
func (c *Connector) LeaderProvider() LeaderProvider
func (*Connector) ObservabilityHandler ¶ added in v0.15.0
func (*Connector) ProxiedPositionProvider ¶ added in v0.11.8
func (c *Connector) ProxiedPositionProvider() ProxiedPositionProvider
func (*Connector) PruneMetadata ¶ added in v0.18.0
PruneMetadata compacts internal HA metadata tables (LWW version/tombstone records and COMMITTED two-phase commit transaction records) older than olderThan.
func (*Connector) QueryRouter ¶ added in v0.13.0
func (*Connector) ReadinessHandler ¶ added in v0.15.0
func (*Connector) RemoveConsumer ¶
func (*Connector) ReplicationID ¶ added in v0.13.0
func (*Connector) ResponseWriter ¶ added in v0.1.3
func (c *Connector) ResponseWriter(w http.ResponseWriter) http.ResponseWriter
func (*Connector) SetProxiedDB ¶ added in v0.11.4
func (*Connector) SetProxiedPositionProvider ¶ added in v0.11.8
func (c *Connector) SetProxiedPositionProvider(provider ProxiedPositionProvider)
func (*Connector) Snapshotter ¶ added in v0.0.13
func (c *Connector) Snapshotter() DBSnapshotter
func (*Connector) Subscriber ¶ added in v0.0.13
func (c *Connector) Subscriber() Subscriber
func (*Connector) TakeSnapshot ¶
type DBPublisher ¶ added in v0.10.7
type DBPublisher struct {
// contains filtered or unexported fields
}
func NewDBPublisher ¶ added in v0.10.7
func (*DBPublisher) Close ¶ added in v0.10.8
func (p *DBPublisher) Close() error
func (*DBPublisher) Publish ¶ added in v0.10.7
func (p *DBPublisher) Publish(ctx context.Context, cs *ChangeSet) error
func (*DBPublisher) SeqNotifyCh ¶ added in v0.18.0
func (p *DBPublisher) SeqNotifyCh() <-chan struct{}
func (*DBPublisher) Sequence ¶ added in v0.10.7
func (p *DBPublisher) Sequence() uint64
type DBSnapshotter ¶ added in v0.0.6
type DBSubscriber ¶ added in v0.10.7
type DBSubscriber struct {
// contains filtered or unexported fields
}
func NewDBSubscriber ¶ added in v0.10.7
func NewDBSubscriber(cfg DBSubscriberConfig) (*DBSubscriber, error)
func (*DBSubscriber) DB ¶ added in v0.11.0
func (s *DBSubscriber) DB() *sql.DB
func (*DBSubscriber) DeliveredInfo ¶ added in v0.10.7
func (*DBSubscriber) HistoryBySeq ¶ added in v0.10.7
func (s *DBSubscriber) HistoryBySeq(ctx context.Context, startSeq uint64) ([]haconnect.HistoryItem, error)
func (*DBSubscriber) HistoryByTime ¶ added in v0.10.7
func (s *DBSubscriber) HistoryByTime(ctx context.Context, duration time.Duration) ([]haconnect.HistoryItem, error)
func (*DBSubscriber) LatestSeq ¶ added in v0.10.7
func (s *DBSubscriber) LatestSeq() uint64
func (*DBSubscriber) RemoveConsumer ¶ added in v0.10.7
func (s *DBSubscriber) RemoveConsumer(ctx context.Context, name string) error
func (*DBSubscriber) SeqNotifyCh ¶ added in v0.18.0
func (s *DBSubscriber) SeqNotifyCh() <-chan struct{}
func (*DBSubscriber) SetDB ¶ added in v0.10.7
func (s *DBSubscriber) SetDB(db *sql.DB)
func (*DBSubscriber) Start ¶ added in v0.10.7
func (s *DBSubscriber) Start() error
func (*DBSubscriber) UndoBySeq ¶ added in v0.10.7
func (s *DBSubscriber) UndoBySeq(ctx context.Context, startSeq uint64, filter haconnect.UndoFilter, filterEntities map[string][]int64) error
func (*DBSubscriber) UndoByTime ¶ added in v0.10.7
func (s *DBSubscriber) UndoByTime(ctx context.Context, duration time.Duration, filterType haconnect.UndoFilter, filterEntities map[string][]int64) error
type DBSubscriberConfig ¶ added in v0.10.7
type DBSubscriberConfig struct {
HistoryDB *sql.DB
DB *sql.DB
ConnProvider ConnHooksProvider
Interceptor ChangeSetInterceptor
RowIdentify RowIdentify
}
type DebeziumData ¶ added in v0.3.0
type DebeziumData struct {
Schema any `json:"schema"`
Payload DebeziumPayload `json:"payload"`
Transaction DebeziumTransaction `json:"transaction"`
}
type DebeziumPayload ¶ added in v0.3.0
type DebeziumSource ¶ added in v0.3.0
type DebeziumTransaction ¶ added in v0.3.0
type DebeziumTransaction struct {
ID string `json:"id"`
}
type DynamicLeader ¶ added in v0.1.1
type DynamicLeader struct {
// contains filtered or unexported fields
}
func StartLeaderElection ¶ added in v0.15.0
func (*DynamicLeader) IsLeader ¶ added in v0.1.1
func (d *DynamicLeader) IsLeader() bool
func (*DynamicLeader) IsReady ¶ added in v0.15.0
func (d *DynamicLeader) IsReady() bool
func (*DynamicLeader) Ready ¶ added in v0.1.1
func (d *DynamicLeader) Ready() chan struct{}
func (*DynamicLeader) RedirectTarget ¶ added in v0.1.1
func (d *DynamicLeader) RedirectTarget() string
type EmbeddedNatsConfig ¶
type FilterInterceptor ¶ added in v0.17.0
type FilterInterceptor struct {
NoopInterceptor
// contains filtered or unexported fields
}
FilterInterceptor filters Changes in a ChangeSet using a predicate function. If all changes in a non-empty ChangeSet are filtered out, BeforeApply returns skip=true.
func NewAllowOperationsInterceptor ¶ added in v0.17.0
func NewAllowOperationsInterceptor(operations ...string) *FilterInterceptor
NewAllowOperationsInterceptor returns an interceptor that only applies changes whose Operation matches one of the specified operations (e.g. "INSERT", "UPDATE", "DELETE", "SQL").
func NewAllowTablesInterceptor ¶ added in v0.17.0
func NewAllowTablesInterceptor(tables ...string) *FilterInterceptor
NewAllowTablesInterceptor returns an interceptor that only applies changes targeting the specified tables.
func NewFilterInterceptor ¶ added in v0.17.0
func NewFilterInterceptor(keep ChangeFilterFunc) *FilterInterceptor
NewFilterInterceptor creates a FilterInterceptor that retains only changes where keep returns true.
func NewIgnoreOperationsInterceptor ¶ added in v0.17.0
func NewIgnoreOperationsInterceptor(operations ...string) *FilterInterceptor
NewIgnoreOperationsInterceptor returns an interceptor that drops changes whose Operation matches any of the specified operations (e.g. "DELETE", "SQL").
func NewIgnoreTablesInterceptor ¶ added in v0.17.0
func NewIgnoreTablesInterceptor(tables ...string) *FilterInterceptor
NewIgnoreTablesInterceptor returns an interceptor that drops changes targeting the specified tables.
func (*FilterInterceptor) BeforeApply ¶ added in v0.17.0
type HistoryCursor ¶ added in v0.16.0
type HistoryCursor struct {
Connector *Connector
Pos int
Rows []haconnect.HistoryItem
}
func (*HistoryCursor) Close ¶ added in v0.16.0
func (vc *HistoryCursor) Close() error
func (*HistoryCursor) ColumnValue ¶ added in v0.16.0
func (vc *HistoryCursor) ColumnValue(col int) any
func (*HistoryCursor) EOF ¶ added in v0.16.0
func (vc *HistoryCursor) EOF() bool
func (*HistoryCursor) FilterValue ¶ added in v0.16.0
func (vc *HistoryCursor) FilterValue(hasVal bool, firstVal any) error
func (*HistoryCursor) Next ¶ added in v0.16.0
func (vc *HistoryCursor) Next() error
func (*HistoryCursor) Rowid ¶ added in v0.16.0
func (vc *HistoryCursor) Rowid() (int64, error)
type HookCallbacks ¶ added in v0.16.0
type JSONPublisher ¶ added in v0.0.6
type JSONPublisher struct {
// contains filtered or unexported fields
}
func NewJSONPublisher ¶ added in v0.0.6
func NewJSONPublisher(w io.Writer) *JSONPublisher
func (*JSONPublisher) Publish ¶ added in v0.0.6
func (p *JSONPublisher) Publish(ctx context.Context, cs *ChangeSet) error
func (*JSONPublisher) Sequence ¶ added in v0.0.20
func (p *JSONPublisher) Sequence() uint64
type LWWConflictHandler ¶ added in v0.17.0
LWWConflictHandler is called whenever an incoming Change is skipped due to a newer local version.
type LWWOption ¶ added in v0.17.0
type LWWOption func(*LastWriterWinsInterceptor)
LWWOption configures a LastWriterWinsInterceptor.
func WithLWWAtomicTransaction ¶ added in v0.17.0
WithLWWAtomicTransaction controls whether a conflict on any single row skips the entire ChangeSet transaction (true) or only drops the stale row Changes (false, default).
func WithLWWIgnoreTables ¶ added in v0.17.0
WithLWWIgnoreTables excludes the given tables from LWW conflict resolution.
func WithLWWOnConflict ¶ added in v0.17.0
func WithLWWOnConflict(fn LWWConflictHandler) LWWOption
WithLWWOnConflict registers a callback invoked whenever an incoming Change loses LWW resolution.
func WithLWWRetentionTTL ¶ added in v0.18.0
WithLWWRetentionTTL configures automatic pruning of LWW version/tombstone entries older than ttl.
func WithLWWTableName ¶ added in v0.17.0
WithLWWTableName sets the local SQLite table name used to store per-row LWW metadata.
func WithLWWTables ¶ added in v0.17.0
WithLWWTables restricts LWW conflict resolution to the given tables. Changes to other tables pass through unmodified.
func WithLWWTieBreaker ¶ added in v0.17.0
func WithLWWTieBreaker(fn LWWTieBreaker) LWWOption
WithLWWTieBreaker sets a custom tie-breaker function for equal timestamps.
type LWWTieBreaker ¶ added in v0.17.0
LWWTieBreaker breaks ties when an incoming change and the local state have the exact same timestamp/version. Returning true means the incoming change wins; returning false keeps the local state.
type LastWriterWinsInterceptor ¶ added in v0.17.0
type LastWriterWinsInterceptor struct {
// contains filtered or unexported fields
}
LastWriterWinsInterceptor implements schema-less Last-Writer-Wins (LWW) conflict resolution using Change.TsNs (falling back to ChangeSet.Timestamp) and a deterministic node-name tie-breaker.
Per-row timestamps and delete tombstones are persisted in a local control table (DefaultLWWTableName by default) and local commits on the origin node are tracked automatically via LocalChangeSetObserver so multi-master clusters converge cleanly without requiring timestamp columns on application tables.
func NewLastWriterWinsInterceptor ¶ added in v0.17.0
func NewLastWriterWinsInterceptor(opts ...LWWOption) *LastWriterWinsInterceptor
NewLastWriterWinsInterceptor creates a new LastWriterWinsInterceptor with the given options.
func (*LastWriterWinsInterceptor) AfterApply ¶ added in v0.17.0
func (*LastWriterWinsInterceptor) BeforeApply ¶ added in v0.17.0
func (*LastWriterWinsInterceptor) OnLocalChangeSet ¶ added in v0.17.0
func (i *LastWriterWinsInterceptor) OnLocalChangeSet(cs *ChangeSet)
OnLocalChangeSet records locally committed row versions so concurrent remote changesets with older timestamps cannot overwrite newer local writes.
type LeaderProvider ¶ added in v0.1.0
type LocalChangeSetObserver ¶ added in v0.17.0
type LocalChangeSetObserver interface {
OnLocalChangeSet(cs *ChangeSet)
}
LocalChangeSetObserver is an optional interface that ChangeSetInterceptor implementations may implement to observe locally committed ChangeSets on the originating node (for example, to record local row timestamps for multi-master conflict resolution before remote changesets arrive).
type NATSPublisher ¶ added in v0.0.6
type NATSPublisher struct {
// contains filtered or unexported fields
}
func NewNATSPublisher ¶ added in v0.0.6
func NewNATSPublisher(nc *nats.Conn, subject string, timeout time.Duration, streamConfig *jetstream.StreamConfig) (*NATSPublisher, error)
func (*NATSPublisher) Publish ¶ added in v0.0.6
func (p *NATSPublisher) Publish(ctx context.Context, cs *ChangeSet) error
func (*NATSPublisher) SeqNotifyCh ¶ added in v0.18.0
func (p *NATSPublisher) SeqNotifyCh() <-chan struct{}
func (*NATSPublisher) Sequence ¶ added in v0.0.20
func (p *NATSPublisher) Sequence() uint64
func (*NATSPublisher) SequenceRange ¶ added in v0.16.2
func (p *NATSPublisher) SequenceRange() (uint64, uint64)
type NATSSnapshotter ¶ added in v0.0.6
type NATSSnapshotter struct {
// contains filtered or unexported fields
}
func NewNATSSnapshotter ¶ added in v0.0.6
func (*NATSSnapshotter) Close ¶ added in v0.18.0
func (s *NATSSnapshotter) Close() error
func (*NATSSnapshotter) DB ¶ added in v0.11.0
func (s *NATSSnapshotter) DB() *sql.DB
func (*NATSSnapshotter) LatestSnapshot ¶ added in v0.0.6
func (s *NATSSnapshotter) LatestSnapshot(ctx context.Context) (uint64, io.ReadCloser, error)
func (*NATSSnapshotter) LatestSnapshotSequence ¶ added in v0.0.6
func (s *NATSSnapshotter) LatestSnapshotSequence(ctx context.Context) (uint64, error)
func (*NATSSnapshotter) LatestSnapshotTime ¶ added in v0.15.0
func (s *NATSSnapshotter) LatestSnapshotTime() time.Time
func (*NATSSnapshotter) SetDB ¶ added in v0.0.13
func (s *NATSSnapshotter) SetDB(db *sql.DB)
func (*NATSSnapshotter) Start ¶ added in v0.0.13
func (s *NATSSnapshotter) Start()
func (*NATSSnapshotter) TakeSnapshot ¶ added in v0.0.6
func (s *NATSSnapshotter) TakeSnapshot(ctx context.Context) (sequence uint64, err error)
type NATSSubscriber ¶ added in v0.0.6
type NATSSubscriber struct {
// contains filtered or unexported fields
}
func NewNATSSubscriber ¶ added in v0.0.6
func NewNATSSubscriber(cfg NATSSubscriberConfig) (*NATSSubscriber, error)
func (*NATSSubscriber) Close ¶ added in v0.18.0
func (s *NATSSubscriber) Close() error
func (*NATSSubscriber) DB ¶ added in v0.11.0
func (s *NATSSubscriber) DB() *sql.DB
func (*NATSSubscriber) DeliveredInfo ¶ added in v0.0.6
func (*NATSSubscriber) HistoryBySeq ¶ added in v0.10.5
func (s *NATSSubscriber) HistoryBySeq(ctx context.Context, startSeq uint64) ([]haconnect.HistoryItem, error)
func (*NATSSubscriber) HistoryByTime ¶ added in v0.10.5
func (s *NATSSubscriber) HistoryByTime(ctx context.Context, duration time.Duration) ([]haconnect.HistoryItem, error)
func (*NATSSubscriber) LatestSeq ¶ added in v0.0.6
func (s *NATSSubscriber) LatestSeq() uint64
func (*NATSSubscriber) RemoveConsumer ¶ added in v0.0.6
func (s *NATSSubscriber) RemoveConsumer(ctx context.Context, name string) error
func (*NATSSubscriber) SeqNotifyCh ¶ added in v0.18.0
func (s *NATSSubscriber) SeqNotifyCh() <-chan struct{}
func (*NATSSubscriber) SetDB ¶ added in v0.0.13
func (s *NATSSubscriber) SetDB(db *sql.DB)
func (*NATSSubscriber) Start ¶ added in v0.0.6
func (s *NATSSubscriber) Start() error
func (*NATSSubscriber) UndoBySeq ¶ added in v0.10.5
func (s *NATSSubscriber) UndoBySeq(ctx context.Context, startSeq uint64, filterType haconnect.UndoFilter, filterEntities map[string][]int64) error
func (*NATSSubscriber) UndoByTime ¶ added in v0.10.3
func (s *NATSSubscriber) UndoByTime(ctx context.Context, duration time.Duration, filterType haconnect.UndoFilter, filterEntities map[string][]int64) error
type NATSSubscriberConfig ¶ added in v0.0.21
type NATSSubscriberConfig struct {
Node string
Durable string
NatsConn *nats.Conn
Stream string
Subject string
Policy string
DB *sql.DB
ConnProvider ConnHooksProvider
Interceptor ChangeSetInterceptor
RowIdentify RowIdentify
}
type NoopInterceptor ¶ added in v0.17.0
type NoopInterceptor struct{}
NoopInterceptor is a no-op ChangeSetInterceptor that allows all changesets. It can be used directly or embedded in custom interceptors that only need to override BeforeApply or AfterApply.
func NewNoopInterceptor ¶ added in v0.17.0
func NewNoopInterceptor() *NoopInterceptor
NewNoopInterceptor returns a new NoopInterceptor.
func (*NoopInterceptor) AfterApply ¶ added in v0.17.0
func (*NoopInterceptor) BeforeApply ¶ added in v0.17.0
type NoopPublisher ¶ added in v0.0.6
type NoopPublisher struct{}
func NewNoopPublisher ¶ added in v0.0.6
func NewNoopPublisher() *NoopPublisher
func (*NoopPublisher) Publish ¶ added in v0.0.6
func (p *NoopPublisher) Publish(ctx context.Context, cs *ChangeSet) error
func (*NoopPublisher) Sequence ¶ added in v0.0.20
func (p *NoopPublisher) Sequence() uint64
type NoopSnapshotter ¶ added in v0.0.6
type NoopSnapshotter struct {
// contains filtered or unexported fields
}
func NewNoopSnapshotter ¶ added in v0.0.6
func NewNoopSnapshotter() *NoopSnapshotter
func (*NoopSnapshotter) DB ¶ added in v0.11.0
func (s *NoopSnapshotter) DB() *sql.DB
func (*NoopSnapshotter) LatestSnapshot ¶ added in v0.0.6
func (s *NoopSnapshotter) LatestSnapshot(ctx context.Context) (uint64, io.ReadCloser, error)
func (*NoopSnapshotter) LatestSnapshotTime ¶ added in v0.15.0
func (s *NoopSnapshotter) LatestSnapshotTime() time.Time
func (*NoopSnapshotter) SetDB ¶ added in v0.0.13
func (s *NoopSnapshotter) SetDB(_ *sql.DB)
func (*NoopSnapshotter) Start ¶ added in v0.0.13
func (s *NoopSnapshotter) Start()
func (*NoopSnapshotter) TakeSnapshot ¶ added in v0.0.6
func (s *NoopSnapshotter) TakeSnapshot(ctx context.Context) (sequence uint64, err error)
type NoopSubscriber ¶ added in v0.0.6
type NoopSubscriber struct{}
func NewNoopSubscriber ¶ added in v0.0.6
func NewNoopSubscriber() *NoopSubscriber
func (*NoopSubscriber) DB ¶ added in v0.11.0
func (s *NoopSubscriber) DB() *sql.DB
func (*NoopSubscriber) DeliveredInfo ¶ added in v0.0.6
func (*NoopSubscriber) HistoryBySeq ¶ added in v0.10.5
func (*NoopSubscriber) HistoryBySeq(ctx context.Context, startSeq uint64) ([]haconnect.HistoryItem, error)
func (*NoopSubscriber) HistoryByTime ¶ added in v0.10.5
func (*NoopSubscriber) HistoryByTime(ctx context.Context, duration time.Duration) ([]haconnect.HistoryItem, error)
func (*NoopSubscriber) LatestSeq ¶ added in v0.0.6
func (s *NoopSubscriber) LatestSeq() uint64
func (*NoopSubscriber) RemoveConsumer ¶ added in v0.0.6
func (*NoopSubscriber) RemoveConsumer(ctx context.Context, name string) error
func (*NoopSubscriber) SetDB ¶ added in v0.0.13
func (s *NoopSubscriber) SetDB(db *sql.DB)
func (*NoopSubscriber) Start ¶ added in v0.0.6
func (s *NoopSubscriber) Start() error
func (*NoopSubscriber) UndoBySeq ¶ added in v0.10.5
func (*NoopSubscriber) UndoBySeq(ctx context.Context, startSeq uint64, filter haconnect.UndoFilter, filterEntities map[string][]int64) error
func (*NoopSubscriber) UndoByTime ¶ added in v0.10.3
func (*NoopSubscriber) UndoByTime(ctx context.Context, duration time.Duration, filter haconnect.UndoFilter, filterEntities map[string][]int64) error
type ObservabilityStatus ¶ added in v0.15.0
type ObservabilityStatus struct {
Status string `json:"status"`
Ready bool `json:"ready"`
NodeName string `json:"node_name"`
ReplicationID string `json:"replication_id"`
Leader bool `json:"leader"`
LeaderTarget string `json:"leader_target,omitempty"`
NATSConfigured bool `json:"nats_configured"`
NATSConnected bool `json:"nats_connected"`
NATSStatus string `json:"nats_status"`
PublishedSequence uint64 `json:"published_sequence"`
AppliedSequence uint64 `json:"applied_sequence"`
ReplicationLag uint64 `json:"replication_lag_messages"`
ReplicationLagByNode map[string]uint64 `json:"replication_lag_by_node"`
LastSnapshotTime *time.Time `json:"last_snapshot_time,omitempty"`
ObservabilityErrors []string `json:"observability_errors,omitempty"`
}
type Option ¶
type Option func(*Connector)
func NameToOptions ¶ added in v0.0.10
func WithAsyncPublisher ¶ added in v0.0.15
func WithAsyncPublisher() Option
func WithAutoStart ¶ added in v0.1.0
func WithBackupFn ¶ added in v0.18.3
func WithCDCPublisher ¶
func WithCDCPublisher(p CDCPublisher) Option
func WithChangeSetInterceptor ¶ added in v0.0.6
func WithChangeSetInterceptor(interceptor ChangeSetInterceptor) Option
func WithClusterSize ¶ added in v0.1.1
func WithDBSnapshotter ¶ added in v0.0.6
func WithDBSnapshotter(snap DBSnapshotter) Option
func WithDeliverPolicy ¶
func WithDisableDDLSync ¶ added in v0.0.4
func WithDisableDDLSync() Option
func WithEmbeddedNatsConfig ¶
func WithEmbeddedNatsConfig(cfg *EmbeddedNatsConfig) Option
func WithExtensions ¶
func WithForcePublishBeforeStart ¶ added in v0.13.1
func WithGrpcInsecure ¶ added in v0.9.2
func WithGrpcPort ¶ added in v0.4.5
func WithGrpcTimeout ¶ added in v0.4.7
func WithGrpcToken ¶ added in v0.7.0
func WithLeaderElectionLocalTarget ¶ added in v0.1.1
func WithLeaderProvider ¶ added in v0.1.1
func WithLeaderProvider(p LeaderProvider) Option
func WithMetadataRetention ¶ added in v0.18.0
WithMetadataRetention configures automatic retention and background compaction for internal HA metadata tables (such as ha_lww_versions tombstones and COMMITTED rows in ha_2pc_transactions).
func WithNatsOptions ¶
func WithOpenTelemetry ¶ added in v0.15.0
func WithOpenTelemetry(meterProvider metric.MeterProvider, tracerProvider trace.TracerProvider) Option
WithOpenTelemetry enables instrumentation using the supplied providers. A nil provider uses the corresponding global OpenTelemetry provider.
func WithProxiedDB ¶ added in v0.11.4
func WithProxiedPositionProvider ¶ added in v0.11.8
func WithProxiedPositionProvider(provider ProxiedPositionProvider) Option
func WithPublisherTimeout ¶
func WithQueryRouter ¶ added in v0.5.5
func WithReplicas ¶
func WithReplicationID ¶ added in v0.3.0
func WithReplicationPublisher ¶ added in v0.3.0
func WithReplicationStream ¶ added in v0.0.9
func WithReplicationSubscriber ¶ added in v0.3.0
func WithReplicationSubscriber(sub Subscriber) Option
func WithReplicationURL ¶
func WithRowIdentify ¶ added in v0.0.21
func WithRowIdentify(i RowIdentify) Option
func WithSnapshotInterval ¶
func WithStreamMaxAge ¶
func WithWaitFor ¶ added in v0.0.4
func WithWaitFor(ch chan struct{}) Option
type OutboxPublisher ¶ added in v0.14.0
type OutboxPublisher struct {
// contains filtered or unexported fields
}
func NewAsyncNATSPublisher ¶ added in v0.0.15
func NewAsyncNATSPublisher(nc *nats.Conn, subject string, timeout time.Duration, streamConfig *jetstream.StreamConfig) (*OutboxPublisher, error)
func NewOutboxPublisher ¶ added in v0.14.0
func NewOutboxPublisher(publisher Publisher, subject string) *OutboxPublisher
func (*OutboxPublisher) BindLocalDB ¶ added in v0.14.0
func (p *OutboxPublisher) BindLocalDB(db *sql.DB) error
BindLocalDB configures the origin database used to persist outbox records.
func (*OutboxPublisher) Close ¶ added in v0.14.0
func (p *OutboxPublisher) Close() error
func (*OutboxPublisher) PrepareTwoPhaseCommit ¶ added in v0.14.0
func (p *OutboxPublisher) PrepareTwoPhaseCommit(_ context.Context, cs *ChangeSet) (PreparedTwoPhaseCommit, error)
func (*OutboxPublisher) Publish ¶ added in v0.14.0
func (p *OutboxPublisher) Publish(ctx context.Context, cs *ChangeSet) error
func (*OutboxPublisher) SeqNotifyCh ¶ added in v0.18.0
func (p *OutboxPublisher) SeqNotifyCh() <-chan struct{}
func (*OutboxPublisher) Sequence ¶ added in v0.14.0
func (p *OutboxPublisher) Sequence() uint64
func (*OutboxPublisher) SequenceRange ¶ added in v0.16.2
func (p *OutboxPublisher) SequenceRange() (uint64, uint64)
type PreparedTwoPhaseCommit ¶ added in v0.13.17
type PreparedTwoPhaseCommit interface {
RecordCommitDecision(context.Context, TwoPhaseCommitDecisionWriter) error
Commit(context.Context) error
Abort() error
ResolveCommit(context.Context) (bool, error)
Close()
}
PreparedTwoPhaseCommit finalizes or aborts a transaction after remote preparation.
type ProxiedPositionProvider ¶ added in v0.11.8
type ProxiedQuerierExecer ¶ added in v0.16.0
type RowIdentify ¶ added in v0.0.21
type RowIdentify string
const ( PK RowIdentify = "pk" Rowid RowIdentify = "rowid" Full RowIdentify = "full" )
type SQLiteConn ¶ added in v0.16.0
type SQLiteConn interface {
driver.Conn
driver.ConnBeginTx
driver.ConnPrepareContext
Deserialize(b []byte, schema string) error
}
func RawSQLiteConn ¶ added in v0.16.0
func RawSQLiteConn(conn *sql.Conn) (SQLiteConn, error)
type SQLiteHooksAdapter ¶ added in v0.16.0
type SQLiteHooksAdapter interface {
WrapConn(c driver.Conn, connector *Connector) (SQLiteConn, error)
EnableHooks(conn SQLiteConn, cb HookCallbacks)
DisableHooks(conn SQLiteConn)
}
type SequenceNotifier ¶ added in v0.18.0
type SequenceNotifier interface {
SeqNotifyCh() <-chan struct{}
}
SequenceNotifier is an optional interface implemented by Publishers and Subscribers that broadcast a channel close whenever their sequence advances, avoiding busy polling.
type SequenceProvider ¶
type SequenceProvider interface {
LatestSeq() uint64
}
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
func ParseStatement ¶ added in v0.0.4
func UnverifiedStatement ¶ added in v0.0.12
func (*Statement) AggregateFunctions ¶ added in v0.6.5
func (*Statement) HasDistinct ¶
func (*Statement) HasReturning ¶
func (*Statement) IsCreateTable ¶
func (*Statement) ModifiesDatabase ¶ added in v0.0.12
func (*Statement) Parameters ¶
func (*Statement) RewriteQueryToAggregate ¶ added in v0.6.5
func (*Statement) SourceWithIfExists ¶ added in v0.0.10
type StaticLeader ¶ added in v0.1.0
type StaticLeader struct {
Target string
}
func (*StaticLeader) IsLeader ¶ added in v0.1.0
func (s *StaticLeader) IsLeader() bool
func (*StaticLeader) IsReady ¶ added in v0.15.0
func (s *StaticLeader) IsReady() bool
func (*StaticLeader) Ready ¶ added in v0.1.1
func (s *StaticLeader) Ready() chan struct{}
func (*StaticLeader) RedirectTarget ¶ added in v0.1.0
func (s *StaticLeader) RedirectTarget() string
type Subscriber ¶ added in v0.3.0
type Subscriber interface {
TxSeqTracker
DB() *sql.DB
SetDB(*sql.DB)
Start() error
RemoveConsumer(ctx context.Context, name string) error
DeliveredInfo(ctx context.Context, name string) (any, error)
HistoryBySeq(ctx context.Context, startSeq uint64) ([]haconnect.HistoryItem, error)
HistoryByTime(ctx context.Context, duration time.Duration) ([]haconnect.HistoryItem, error)
UndoBySeq(ctx context.Context, startSeq uint64, filterType haconnect.UndoFilter, filterEntities map[string][]int64) error
UndoByTime(ctx context.Context, duration time.Duration, filterType haconnect.UndoFilter, filterEntities map[string][]int64) error
}
type TwoPhaseCommitDecisionWriter ¶ added in v0.13.17
TwoPhaseCommitDecisionWriter records the commit decision in the origin transaction.
type TwoPhaseCommitPreparer ¶ added in v0.13.17
type TwoPhaseCommitPreparer interface {
PrepareTwoPhaseCommit(context.Context, *ChangeSet) (PreparedTwoPhaseCommit, error)
}
TwoPhaseCommitPreparer starts the remote prepare phase for an origin transaction.
type TwoPhaseCommitPublisher ¶ added in v0.12.1
type TwoPhaseCommitPublisher struct {
// contains filtered or unexported fields
}
func NewTwoPhaseCommitPublisher ¶ added in v0.12.1
func (*TwoPhaseCommitPublisher) BindLocalDB ¶ added in v0.13.17
func (p *TwoPhaseCommitPublisher) BindLocalDB(db *sql.DB) error
BindLocalDB configures the origin database used to persist and recover decisions.
func (*TwoPhaseCommitPublisher) Close ¶ added in v0.18.0
func (p *TwoPhaseCommitPublisher) Close() error
func (*TwoPhaseCommitPublisher) PrepareTwoPhaseCommit ¶ added in v0.13.17
func (p *TwoPhaseCommitPublisher) PrepareTwoPhaseCommit(ctx context.Context, cs *ChangeSet) (PreparedTwoPhaseCommit, error)
PrepareTwoPhaseCommit prepares each configured remote participant concurrently.
func (*TwoPhaseCommitPublisher) Publish ¶ added in v0.12.1
func (p *TwoPhaseCommitPublisher) Publish(ctx context.Context, cs *ChangeSet) (err error)
func (*TwoPhaseCommitPublisher) RecoverTwoPhaseCommits ¶ added in v0.13.17
func (p *TwoPhaseCommitPublisher) RecoverTwoPhaseCommits(ctx context.Context) error
RecoverTwoPhaseCommits replays durable local decisions before new transactions begin.
func (*TwoPhaseCommitPublisher) Sequence ¶ added in v0.12.1
func (p *TwoPhaseCommitPublisher) Sequence() uint64
type TxSeqTracker ¶ added in v0.4.8
type TxSeqTracker interface {
LatestSeq() uint64
}
type TxSeqTrackerProvider ¶ added in v0.4.8
type TxSeqTrackerProvider func() TxSeqTracker
type WriterPublisher ¶ added in v0.0.6
type WriterPublisher struct {
// contains filtered or unexported fields
}
func NewWriterPublisher ¶ added in v0.0.6
func NewWriterPublisher(w io.Writer, serializer ChangeSetSerializer) *WriterPublisher
func (*WriterPublisher) Publish ¶ added in v0.0.6
func (p *WriterPublisher) Publish(ctx context.Context, cs *ChangeSet) error
func (*WriterPublisher) Sequence ¶ added in v0.0.20
func (p *WriterPublisher) Sequence() uint64