File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ root = true
2
+
3
+ [* ]
4
+ end_of_line = lf
5
+ insert_final_newline = false
6
+ charset = utf-8
7
+ indent_style = tab
Original file line number Diff line number Diff line change
1
+ {
2
+ "diagnostics" : {
3
+ "disable" : [" lowercase-global" ],
4
+ "globals" : [" peerdb" ]
5
+ }
6
+ }
7
+
Original file line number Diff line number Diff line change
1
+ local msgpack = require ' msgpack'
2
+
3
+ local function RowToMap (row )
4
+ local cols = peerdb .RowColumns (row )
5
+ local map = {}
6
+ for _ , col in ipairs (cols ) do
7
+ local kind = peerdb .RowColumnKind (row , col )
8
+ if string.sub (kind , 1 , # ' array_' ) == ' array_' then
9
+ map [col ] = msgpack .array (row [col ])
10
+ elseif kind == ' numeric' then
11
+ local dec = row [col ]
12
+ map [col ] = msgpack .ext (10 , msgpack .encode (dec .exponent ) .. dec .coefficient .bytes )
13
+ elseif kind == ' bytes' or kind == ' bit' then
14
+ map [col ] = msgpack .bin (row [col ])
15
+ else
16
+ map [col ] = row [col ]
17
+ end
18
+ end
19
+ return map
20
+ end
21
+
22
+ local RKINDMAP = {
23
+ insert = string.byte (' i' , 1 ),
24
+ update = string.byte (' u' , 1 ),
25
+ delete = string.byte (' d' , 1 ),
26
+ }
27
+
28
+ function onRecord (r )
29
+ local kind = RKINDMAP [r .kind ]
30
+ if not kind then
31
+ return
32
+ end
33
+ local record = {
34
+ action = r .kind ,
35
+ lsn = r .checkpoint ,
36
+ time = r .commit_time ,
37
+ source = r .source ,
38
+ }
39
+ if r .old then
40
+ record .old = RowToMap (r .old )
41
+ end
42
+ if r .new then
43
+ record .new = RowToMap (r .new )
44
+ end
45
+ return msgpack .encode (record )
46
+ end
You can’t perform that action at this time.
0 commit comments