wal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	// ID is a pgstream assigned immutable column id. Id does not change when column is renamed.
	ID    string `json:"id"`
	Name  string `json:"name"`
	Type  string `json:"type"`
	Value any    `json:"value"`
}

type CommitPosition

type CommitPosition string

CommitPosition represents a position in the input stream

type Data

type Data struct {
	Action    string   `json:"action"`    // "I" -- insert, "U" -- update, "D" -- delete, "T" -- truncate
	Timestamp string   `json:"timestamp"` // ISO8601, i.e. 2019-12-29 04:58:34.806671
	LSN       string   `json:"lsn"`
	Schema    string   `json:"schema"`
	Table     string   `json:"table"`
	Columns   []Column `json:"columns"`
	Identity  []Column `json:"identity"`
	Metadata  Metadata `json:"metadata"` // pgstream specific metadata
}

Data contains the wal data properties identifying the table operation.

func (*Data) GetTimestamp

func (d *Data) GetTimestamp() (time.Time, error)

func (*Data) IsInsert

func (d *Data) IsInsert() bool

func (*Data) IsUpdate

func (d *Data) IsUpdate() bool

type Event

type Event struct {
	Data           *Data
	CommitPosition CommitPosition
}

Event represents the WAL information. If the data is nil but there's a commit position present, it represents a keep alive event that needs to be checkpointed.

type Metadata

type Metadata struct {
	SchemaID        xid.ID `json:"schema_id"`         // the schema ID the event was stamped with
	TablePgstreamID string `json:"table_pgstream_id"` // the ID of the table to which the event belongs
	// This is the Pgstream ID of the "id" column(s). We track this specifically, as we extract it from the event
	// in order to use as the ID for the record.
	InternalColIDs []string `json:"id_col_pgstream_id"`
	// This is the Pgstream ID of the "version" column. We track this specifically, as we extract it from the event
	// in order to use as the version when working with optimistic concurrency checks.
	InternalColVersion string `json:"version_col_pgstream_id"`
}

Metadata is pgstream specific properties to help identify the id/version within the wal event as well as some pgstream unique immutable ids for the schema and the table it relates to.

func (Metadata) IsEmpty

func (m Metadata) IsEmpty() bool

IsEmpty returns true if the pgstream metadata hasn't been populated, false otherwise.

func (Metadata) IsIDColumn

func (m Metadata) IsIDColumn(colID string) bool

IsIDColumn returns true if the column id on input is part of the pgstream identified identity columns.

func (Metadata) IsVersionColumn

func (m Metadata) IsVersionColumn(colID string) bool

IsVersionColumn returns true if the column id on input matches the pgstream identified version column.

Jump to

Keyboard shortcuts

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