cdc

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Schema  Schema  `json:"schema"`
	Payload Payload `json:"payload"`
}

Event represents a complete change data capture event

type EventBuilder

type EventBuilder struct {
	// contains filtered or unexported fields
}

EventBuilder helps construct complete CDC events

func NewEventBuilder

func NewEventBuilder() *EventBuilder

func (*EventBuilder) Build

func (b *EventBuilder) Build() Event

func (*EventBuilder) WithAfter

func (b *EventBuilder) WithAfter(after interface{}) *EventBuilder

func (*EventBuilder) WithBefore

func (b *EventBuilder) WithBefore(before interface{}) *EventBuilder

func (*EventBuilder) WithOperation

func (b *EventBuilder) WithOperation(op Operation) *EventBuilder

func (*EventBuilder) WithSource

func (b *EventBuilder) WithSource(source Source) *EventBuilder

func (*EventBuilder) WithTimestamp

func (b *EventBuilder) WithTimestamp(ts int64) *EventBuilder

func (*EventBuilder) WithTransaction

func (b *EventBuilder) WithTransaction(tx *Transaction) *EventBuilder

type Field

type Field struct {
	Field    string  `json:"field"`
	Type     string  `json:"type"`
	Optional bool    `json:"optional"`
	Name     string  `json:"name,omitempty"`
	Fields   []Field `json:"fields,omitempty"`
}

Field represents a schema field definition

type Operation

type Operation string

Operation represents the type of change that occurred

const (
	OpCreate   Operation = "c"
	OpUpdate   Operation = "u"
	OpDelete   Operation = "d"
	OpRead     Operation = "r"
	OpTruncate Operation = "t"
)

type Payload

type Payload struct {
	Before      interface{}  `json:"before"`
	After       interface{}  `json:"after"`
	Source      Source       `json:"source"`
	Op          Operation    `json:"op"`
	TsMs        int64        `json:"ts_ms"`
	Transaction *Transaction `json:"transaction,omitempty"`
}

Payload represents the actual change data

type Schema

type Schema struct {
	Type     string  `json:"type"`
	Optional bool    `json:"optional"`
	Name     string  `json:"name"`
	Fields   []Field `json:"fields"`
}

Schema represents the schema definition for a change event

type Source

type Source struct {
	Version   string `json:"version"`
	Connector string `json:"connector"`
	Name      string `json:"name"`
	TsMs      int64  `json:"ts_ms"`
	Snapshot  bool   `json:"snapshot"`
	Db        string `json:"db"`
	Sequence  string `json:"sequence"`
	Schema    string `json:"schema"`
	Table     string `json:"table"`
	TxID      int64  `json:"txId"`
	Lsn       int64  `json:"lsn"`
	Xmin      *int64 `json:"xmin,omitempty"`
}

Source contains metadata about where a change originated

type SourceBuilder

type SourceBuilder struct {
	// contains filtered or unexported fields
}

SourceBuilder helps construct Source objects with reasonable defaults

func NewSourceBuilder

func NewSourceBuilder(connector, name string) *SourceBuilder

func (*SourceBuilder) Build

func (b *SourceBuilder) Build() Source

func (*SourceBuilder) WithDatabase

func (b *SourceBuilder) WithDatabase(db string) *SourceBuilder

func (*SourceBuilder) WithSchema

func (b *SourceBuilder) WithSchema(schema string) *SourceBuilder

func (*SourceBuilder) WithTable

func (b *SourceBuilder) WithTable(table string) *SourceBuilder

func (*SourceBuilder) WithTimestamp

func (b *SourceBuilder) WithTimestamp(ts int64) *SourceBuilder

func (*SourceBuilder) WithTransaction

func (b *SourceBuilder) WithTransaction(txID int64, lsn int64) *SourceBuilder

type Transaction

type Transaction struct {
	ID                  string `json:"id"`
	TotalOrder          int64  `json:"total_order"`
	DataCollectionOrder int64  `json:"data_collection_order"`
}

Transaction contains metadata about the transaction this change belongs to

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL