Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 1.19 KB

commonformat.md

File metadata and controls

39 lines (32 loc) · 1.19 KB

Common JSON format

The intention is to define format general enough to transit modification events of different databases.

CommonFormatEvent structure has the following fields:

  • Type - type of event: insert, delete, schema. updates is produces as delete/insert pair
  • Key - primary key of the row, encoded as an array
  • SeqNo - event sequence number generated by the reader
  • Timestamp - timestamp of the moment when event generated by the reader
  • Fields - Array of name/value pairs, empty for delete event

Import types/format.go in order to unmarshal events in Golang.

Examples of events:

Insert event:

{   "Type":"insert",
    "Key":["part1","part2"],
    "SeqNo":123,
    "Timestamp":1494315140,
    "Fields": [
        {"Name":"f1","Value":1},
        {"Name":"f3","Value":"string field"},
        {"Name":"f4","Value":null}
    ]
}

Delete event:

{ "Type":"delete", "Key":["key1"], "SeqNo":124, "Timestamp":1494315140}

Schema event:

{"Type":"schema","Key":["f1"],"SeqNo":125,"Timestamp":1494315140,"Fields":[{"Name":"f1","Value":"int(11)"},{"Name":"f3","Value":"int(11)"},{"Name":"f4","Value":"int(11)"}]}