pg_v_man/core/domain/repl_event.go
2025-02-14 08:44:34 +01:00

44 lines
949 B
Go

package domain
type EventType string
func (e EventType) String() string {
return string(e)
}
const (
EventTypeInsert EventType = "INSERT"
EventTypeUpdate EventType = "UPDATE"
EventTypeDelete EventType = "DELETE"
EventTypeTruncate EventType = "TRUNCATE"
)
func NewValues() *Values {
return &Values{
Key: make(map[string]any),
Data: make(map[string]any),
}
}
func (v *Values) AddValue(partOfKey bool, key string, value any) {
if partOfKey {
v.Key[key] = value
} else {
v.Data[key] = value
}
}
type Values struct {
Key map[string]any
Data map[string]any
}
type ReplicationEvent struct {
EventType EventType `json:"eventType"`
TransactionId uint32 `json:"transactionId"`
DBName string `json:"dbName"`
Namespace string `json:"namespace"`
Relation string `json:"relation"`
NewValues *Values `json:"newValues,omitempty"`
OldValues *Values `json:"oldValues,omitempty"`
}