Documentation
¶
Index ¶
- Constants
- Variables
- func Backup(ctx context.Context, db *sql.DB, w io.Writer) error
- func LatestSnapshot(ctx context.Context, options ...Option) (sequence uint64, reader io.ReadCloser, err error)
- type CDCPublisher
- type Change
- type ChangeSet
- type Conn
- type ConnectHookFn
- type Connector
- func (c *Connector) Close()
- func (c *Connector) Connect(ctx context.Context) (driver.Conn, error)
- func (c *Connector) DeliveredInfo(ctx context.Context, name string) ([]*jetstream.ConsumerInfo, error)
- func (c *Connector) Driver() driver.Driver
- func (c *Connector) LatestSeq() uint64
- func (c *Connector) LatestSnapshot(ctx context.Context) (uint64, io.ReadCloser, error)
- func (c *Connector) RemoveConsumer(ctx context.Context, name string) error
- func (c *Connector) TakeSnapshot(ctx context.Context, db *sql.DB) (sequence uint64, err error)
- type Driver
- type EmbeddedNatsConfig
- type Option
- func WithCDCPublisher(pub CDCPublisher) Option
- func WithConnectHook(fn ConnectHookFn) Option
- func WithDeliverPolicy(deliverPolicy string) Option
- func WithDisableDDLSync() Option
- func WithEmbeddedNatsConfig(cfg *EmbeddedNatsConfig) Option
- func WithExtensions(extensions ...string) Option
- func WithName(name string) Option
- func WithNatsOptions(options ...nats.Option) Option
- func WithPublisherTimeout(timeout time.Duration) Option
- func WithReplicas(replicas int) Option
- func WithReplicationSubject(subject string) Option
- func WithReplicationURL(url string) Option
- func WithSnapshotInterval(interval time.Duration) Option
- func WithStreamMaxAge(maxAge time.Duration) Option
- func WithWaitFor(ch chan struct{}) Option
- type SequenceProvider
- type Statement
- 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) Parameters() []string
- func (s *Statement) Rollback() bool
- func (s *Statement) Source() string
- func (s *Statement) Type() string
Constants ¶
View Source
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" TypeOther = "OTHER" )
View Source
const DefaultStream = "ha_replication"
Variables ¶
View Source
var (
ErrInvalidSQL = fmt.Errorf("invalid SQL")
)
View Source
var ErrNatsNotConfigured = errors.New("NATS not configured")
Functions ¶
func LatestSnapshot ¶ added in v0.0.4
Types ¶
type CDCPublisher ¶
type Change ¶
type Change struct {
Database string `json:"database,omitempty"`
Table string `json:"table,omitempty"`
Columns []string `json:"columns,omitempty"`
Operation string `json:"operation"` // "INSERT", "UPDATE", "DELETE", "SQL"
OldRowID int64 `json:"old_rowid,omitempty"`
NewRowID int64 `json:"new_rowid,omitempty"`
OldValues []any `json:"old_values,omitempty"`
NewValues []any `json:"new_values,omitempty"`
SQL string `json:"sql,omitempty"`
SQLArgs []any `json:"sql_args,omitempty"`
}
type ChangeSet ¶
type ChangeSet struct {
Node string `json:"node"`
ProcessID int64 `json:"process_id"`
Filename string `json:"filename"`
Changes []Change `json:"changes"`
Timestamp int64 `json:"timestamp_ns"`
StreamSeq uint64 `json:"-"`
// contains filtered or unexported fields
}
func NewChangeSet ¶
func NewChangeSet(node string, filename string, publisher CDCPublisher) *ChangeSet
func (*ChangeSet) Send ¶
func (cs *ChangeSet) Send(pub CDCPublisher) error
type Conn ¶
type Conn struct {
*sqlite3.SQLiteConn
// contains filtered or unexported fields
}
type ConnectHookFn ¶ added in v0.0.2
type ConnectHookFn func(conn *sqlite3.SQLiteConn) error
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
func (*Connector) DeliveredInfo ¶
func (*Connector) LatestSnapshot ¶
func (*Connector) RemoveConsumer ¶
type Driver ¶ added in v0.0.2
type Driver struct {
Extensions []string
ConnectHook ConnectHookFn
Options []Option
}
type EmbeddedNatsConfig ¶
type Option ¶
type Option func(*Connector)
func WithCDCPublisher ¶
func WithCDCPublisher(pub CDCPublisher) Option
func WithConnectHook ¶ added in v0.0.2
func WithConnectHook(fn ConnectHookFn) Option
func WithDeliverPolicy ¶
func WithDisableDDLSync ¶ added in v0.0.4
func WithDisableDDLSync() Option
func WithEmbeddedNatsConfig ¶
func WithEmbeddedNatsConfig(cfg *EmbeddedNatsConfig) Option
func WithExtensions ¶
func WithNatsOptions ¶
func WithPublisherTimeout ¶
func WithReplicas ¶
func WithReplicationSubject ¶
func WithReplicationURL ¶
func WithSnapshotInterval ¶
func WithStreamMaxAge ¶
func WithWaitFor ¶ added in v0.0.4
func WithWaitFor(ch chan struct{}) Option
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 (*Statement) HasDistinct ¶
func (*Statement) HasReturning ¶
func (*Statement) IsCreateTable ¶
func (*Statement) Parameters ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.