Documentation
¶
Index ¶
Constants ¶
const ( // CommitMsgType protocol commit message type. CommitMsgType byte = 'C' // BeginMsgType protocol begin message type. BeginMsgType byte = 'B' // OriginMsgType protocol original message type. OriginMsgType byte = 'O' // RelationMsgType protocol relation message type. RelationMsgType byte = 'R' // TypeMsgType protocol message type. TypeMsgType byte = 'Y' // InsertMsgType protocol insert message type. InsertMsgType byte = 'I' // UpdateMsgType protocol update message type. UpdateMsgType byte = 'U' // DeleteMsgType protocol delete message type. DeleteMsgType byte = 'D' // NewTupleDataType protocol new tuple data type. NewTupleDataType byte = 'N' // TextDataType protocol test data type. TextDataType byte = 't' // NullDataType protocol NULL data type. NullDataType byte = 'n' // ToastDataType protocol toast data type. ToastDataType byte = 'u' )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ActionData ¶
type ActionData struct {
Schema string
Table string
Kind ActionKind
Columns []Column
}
ActionData kind of WAL message data.
type ActionKind ¶
type ActionKind string
ActionKind kind of action on WAL message.
const ( ActionKindInsert ActionKind = "INSERT" ActionKindUpdate ActionKind = "UPDATE" ActionKindDelete ActionKind = "DELETE" )
kind of WAL message.
type Begin ¶
type Begin struct {
// Identifies the message as a begin message.
LSN int64
// Commit timestamp of the transaction.
Timestamp time.Time
// Xid of the transaction.
XID int32
}
Begin message format.
type BinaryParser ¶
type BinaryParser struct {
// contains filtered or unexported fields
}
BinaryParser represent binary protocol parser. WAL 二进制解析器
func NewBinaryParser ¶
func NewBinaryParser(byteOrder binary.ByteOrder) *BinaryParser
NewBinaryParser create instance of binary parser.
func (*BinaryParser) ParseMessage ¶
func (p *BinaryParser) ParseMessage(msg []byte, tx *Transaction) error
ParseMessage parse postgres WAL message. 解析 WAL 消息
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
Column of the table with which changes occur.
func (*Column) AssertValue ¶
AssertValue converts bytes to a specific type depending on the type of this data in the database table.
type Commit ¶
type Commit struct {
// Flags; currently unused (must be 0).
Flags int8
// The LSN of the commit.
LSN int64
// The end LSN of the transaction.
TransactionLSN int64
// Commit timestamp of the transaction.
Timestamp time.Time
}
Commit message format.
type DataType ¶
type DataType struct {
// ID of the data type.
ID int32
// Namespace (empty string for pg_catalog).
Namespace string
// name of the data type.
Name string
}
DataType path of WAL message data.
type Delete ¶
type Delete struct {
/// ID of the relation corresponding to the ID in the relation message.
RelationID int32
// Identifies the following TupleData submessage as a key.
KeyTuple bool
// Identifies the following TupleData message as a old tuple.
OldTuple bool
// TupleData message part representing the contents of new tuple.
Row []TupleData
}
Delete message format.
type Insert ¶
type Insert struct {
/// ID of the relation corresponding to the ID in the relation message.
RelationID int32
// Identifies the following TupleData message as a new tuple.
NewTuple bool
// TupleData message part representing the contents of new tuple.
Row []TupleData
}
Insert message format.
type Origin ¶
type Origin struct {
// The LSN of the commit on the origin server.
LSN int64
// name of the origin.
Name string
}
Origin message format.
type Relation ¶
type Relation struct {
// ID of the relation.
ID int32
// Namespace (empty string for pg_catalog).
Namespace string
// Relation name.
Name string
// Replica identity setting for the relation (same as relreplident in pg_class).
Replica int8
Columns []RelationColumn
}
Relation message format.
type RelationColumn ¶
type RelationColumn struct {
// Flags for the column which marks the column as part of the key.
Key bool
// name of the column.
Name string
// ID of the column's data type.
TypeID int32
// valueType modifier of the column (atttypmod).
ModifierType int32
}
RelationColumn path of WAL message data.
type RelationData ¶
RelationData kind of WAL message data.
type Transaction ¶
type Transaction struct {
LSN int64
BeginTime *time.Time
CommitTime *time.Time
RelationStore map[int32]RelationData
Actions []ActionData
}
Transaction transaction specified WAL message.
func NewTransaction ¶
func NewTransaction() *Transaction
NewTransaction create and initialize new WAL transaction.
func (Transaction) CreateActionData ¶
func (w Transaction) CreateActionData( relationID int32, rows []TupleData, kind ActionKind, ) (a ActionData, err error)
CreateActionData create action from WAL message data.
func (*Transaction) CreateEventsWithFilter ¶
func (w *Transaction) CreateEventsWithFilter(tableMap map[string][]string) []*event.Event
CreateEventsWithFilter filter WAL message by table, action and create events for each value.
type Update ¶
type Update struct {
/// ID of the relation corresponding to the ID in the relation message.
RelationID int32
// Identifies the following TupleData submessage as a key.
KeyTuple bool
// Identifies the following TupleData message as a old tuple.
OldTuple bool
// Identifies the following TupleData message as a new tuple.
NewTuple bool
// TupleData message part representing the contents of new tuple.
Row []TupleData
// TupleData message part representing the contents of the old tuple or primary key.
//Only present if the previous 'O' or 'K' part is present.
OldRow []TupleData
}
Update message format.