/
types.go
54 lines (42 loc) · 1.25 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package types
import (
"context"
"github.com/gorilla/websocket"
"github.com/jackc/pgx"
)
// Session stores the context, active db and ws connections, and replication slot state
type Session struct {
Ctx context.Context
CancelFunc context.CancelFunc
ReplConn *pgx.ReplicationConn
PGConn *pgx.Conn
WSConn *websocket.Conn
SlotName string
SnapshotName string
RestartLSN uint64
}
// SnapshotDataJSON is the struct that binds with an incoming request for snapshot data
type SnapshotDataJSON struct {
// SlotName is the name of the replication slot for which the snapshot data needs to be fetched
// (not used as of now, will be useful in multi client setup)
SlotName string `json:"slotName" binding:"omitempty"`
Table string `json:"table" binding:"required"`
Offset *uint `json:"offset" binding:"exists"`
Limit *uint `json:"limit" binding:"exists"`
OrderBy *OrderBy `json:"order_by" binding:"exists"`
}
type OrderBy struct {
Column string `json:"column" binding:"exists"`
Order string `json:"order" binding:"exists"`
// Nulls TODO
}
type Wal2JSONEvent struct {
NextLSN string `json:"nextlsn"`
Change []map[string]interface{}
}
/*
type Wal2JSONChange struct{
Kind string `json:"kind"`
Schema string `json:"schema"`
}
*/