Documentation ¶
Index ¶
Constants ¶
const PGOutput = "pgoutput"
PGOutput is the Postgres recognised name of our desired encoding
Variables ¶
This section is empty.
Functions ¶
func DecodePGOutput ¶
func DecodePGOutput(src []byte) (Message, MessageType, error)
DecodePGOutput parses a pgoutput logical replication message, as per the format specification at:
https://www.postgresql.org/docs/current/static/protocol-logicalrep-message-formats.html
Types ¶
type Column ¶
type Column struct { Key bool `json:"key"` // Interpreted from flags, which are either 0 or 1 which marks the column as part of the key. Name string `json:"name"` // Name of the column. Type uint32 `json:"type"` // ID of the column's data type. Modifier uint32 `json:"modifier"` // Type modifier of the column (atttypmod). }
type Delete ¶
type Delete struct { ID uint32 // ID of the relation corresponding to the ID in the relation message. Key bool // True if the update changed data in any of the column(s) that are part of the REPLICA IDENTITY index. Old bool // True if populated the OldRow value. OldRow []Element // Old value of this row. }
type Insert ¶
type Message ¶
type Message interface{}
Message is a parsed pgoutput message received from the replication stream
type MessageType ¶ added in v0.6.0
type MessageType string
MessageType provides an enum string representing the type of message. It can be used to easily label metrics, or for logging.
const ( MessageTypeBegin MessageType = "Begin" MessageTypeCommit MessageType = "Commit" MessageTypeOrigin MessageType = "Origin" MessageTypeRelation MessageType = "Relation" MessageTypeType MessageType = "Type" MessageTypeInsert MessageType = "Insert" MessageTypeUpdate MessageType = "Update" MessageTypeDelete MessageType = "Delete" MessageTypeTruncate MessageType = "Truncate" )
type Modification ¶ added in v0.6.0
Modification is a common interface satisfied by messages that have altered data. These are inserts, updates, and deletes.
type Relation ¶
type Relation struct { ID uint32 `json:"id"` // ID of the relation. Namespace string `json:"namespace"` // Namespace (empty string for pg_catalog). Name string `json:"name"` // Relation name. ReplicaIdentity uint8 `json:"replica_identity"` // Replica identity setting for the relation (same as relreplident in pg_class). Columns []Column `json:"columns"` // Repeating message of column definitions. }
Relation would normally include a column count field, but given Go slices track their size it becomes unnecessary.
type Update ¶
type Update struct { ID uint32 // ID of the relation corresponding to the ID in the relation message. Key bool // True if the update changed data in any of the column(s) that are part of the REPLICA IDENTITY index. Old bool // True if populated the OldRow value. New bool // True if populated the Row value. OldRow []Element // Old value of this row, only present if Old or Key. Row []Element // New contents of the tuple. }