core

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Begin

type Begin struct {
	// The final LSN of the transaction.
	LSN uint64
	// Commit timestamp of the transaction. The value is in number of
	// microseconds since PostgreSQL epoch (2000-01-01).
	Timestamp time.Time
	// 	Xid of the transaction.
	XID int32
}

type Column

type Column struct {
	Key  bool
	Name string
	Type uint32
	Mode uint32
}

func (Column) Decoder

func (c Column) Decoder() DecoderValue

type Commit

type Commit struct {
	Flags uint8
	// The final LSN of the transaction.
	LSN uint64
	// The final LSN of the transaction.
	TransactionLSN uint64
	Timestamp      time.Time
}

type DMLHandlerStatus added in v1.0.0

type DMLHandlerStatus int
const (
	DMLHandlerStatusSuccess  DMLHandlerStatus = 0 //wal lsn游标将会变动
	DMLHandlerStatusContinue DMLHandlerStatus = 1 //wal lsn游标不会变动
)

type DecoderValue

type DecoderValue interface {
	pgtype.TextDecoder
	pgtype.Value
}

type Delete

type Delete struct {
	/// ID of the relation corresponding to the ID in the relation message.
	RelationID uint32
	// Identifies the following TupleData message as a new tuple.
	Key bool // TODO
	Old bool // TODO
	Row []Tuple
}

type EventType

type EventType int
const (
	EventType_READY    EventType = 0
	EventType_INSERT   EventType = 1
	EventType_UPDATE   EventType = 2
	EventType_DELETE   EventType = 3
	EventType_TRUNCATE EventType = 4
	EventType_COMMIT   EventType = 10
)

type Insert

type Insert struct {
	/// ID of the relation corresponding to the ID in the relation message.
	RelationID uint32
	// Identifies the following TupleData message as a new tuple.
	New bool
	Row []Tuple
}

type Message

type Message interface {
	// contains filtered or unexported methods
}

func Parse

func Parse(src []byte) (Message, error)

Parse a logical replication message. See https://www.postgresql.org/docs/current/static/protocol-logicalrep-message-formats.html

type Origin

type Origin struct {
	LSN  uint64
	Name string
}

type Relation

type Relation struct {
	// ID of the relation.
	ID uint32
	// Namespace (empty string for pg_catalog).
	Namespace string
	Name      string
	Replica   uint8
	Columns   []Column
}

type RelationSet

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

func NewRelationSet

func NewRelationSet() *RelationSet

func (*RelationSet) Add

func (rs *RelationSet) Add(r Relation)

func (*RelationSet) Assist

func (rs *RelationSet) Assist(id uint32) (schema, table string)

func (*RelationSet) Values

func (rs *RelationSet) Values(id uint32, row []Tuple) (values map[string]pgtype.Value, err error)

type ReplicaIdentity added in v1.1.3

type ReplicaIdentity string

表复制标识枚举

const (
	// ReplicaIdentityFull
	// 需要开启replica identity full权限的表
	// 逻辑复制-更改复制标识
	// 默认情况下,复制标识就是主键(如果有主键)。
	// 也可以在复制标识上设置另一个唯一索引(有特定的额外要求)。
	// 如果表没有合适的键,那么可以设置成复制标识“full”,它表示整个行都成为那个键。
	// 不过,这样做效率很低,只有在没有其他方案的情况下才应该使用。
	ReplicaIdentityFull ReplicaIdentity = "FULL"
	// ReplicaIdentityDefault
	// 默认按照主键id为复制标识
	// update时无法得知详细更新column信息
	ReplicaIdentityDefault ReplicaIdentity = "DEFAULT"
)

type Replication added in v1.1.5

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

func NewReplication added in v1.1.5

func NewReplication(name string, config pgx.ConnConfig) *Replication

func (*Replication) Close added in v1.1.5

func (t *Replication) Close()

func (*Replication) CreatePublication added in v1.1.5

func (t *Replication) CreatePublication(tables []string) error

CreatePublication 移除复制槽

func (*Replication) CreateReplication added in v1.1.5

func (t *Replication) CreateReplication() (err error)

CreateReplication 创建逻辑复制槽 锁定起始lsn位置

func (*Replication) Debug added in v1.1.5

func (t *Replication) Debug() *Replication

func (*Replication) DropPublication added in v1.1.5

func (t *Replication) DropPublication() error

DropPublication 移除复制槽

func (*Replication) DropReplication added in v1.1.5

func (t *Replication) DropReplication() error

DropReplication 移除复制槽

func (*Replication) SendStatusACK added in v1.1.5

func (t *Replication) SendStatusACK(lsn uint64) error

SendStatusACK 向master发送lsn,即:WAL中使用者已经收到解码数据的最新位置 详见:select * from pg_catalog.pg_replication_slots;结果中的confirmed_flush_lsn

func (*Replication) SetReplicaIdentity added in v1.1.5

func (t *Replication) SetReplicaIdentity(tables []string, status ReplicaIdentity) (err error)

SetReplicaIdentity 配置表复制标识

func (*Replication) Start added in v1.1.5

func (t *Replication) Start(ctx context.Context, dmlHandler ReplicationDMLHandler) (err error)

type ReplicationDMLHandler

type ReplicationDMLHandler func(msg ...ReplicationMessage) DMLHandlerStatus

type ReplicationMessage

type ReplicationMessage struct {
	Lsn        uint64
	RelationID uint32
	EventType  EventType
	SchemaName string
	TableName  string
	Body       map[string]interface{}
	Columns    []string
}

type Truncate added in v1.1.0

type Truncate struct {
	/// ID of the relation corresponding to the ID in the relation message.
	RelationID uint32
}

type Tuple

type Tuple struct {
	Flag  int8
	Value []byte
}

type Type

type Type struct {
	// ID of the data type
	ID        uint32
	Namespace string
	Name      string
}

type Update

type Update struct {
	/// ID of the relation corresponding to the ID in the relation message.
	RelationID uint32
	// Identifies the following TupleData message as a new tuple.
	Old    bool
	Key    bool
	New    bool
	OldRow []Tuple
	Row    []Tuple
}

Jump to

Keyboard shortcuts

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