I want to be able to setup a lockstep stream off of any postgres table/view that has the few fields required by the protocol, and it will stream that table via lockstep, including any arbitrary data fields it includes.
Chunked HTTP
-
A row will be returned as a JSON object:
{ "txid": 549163, "current_xmin": 551033, "since": 549163, "deleted": true, "data": { "name": "mydomain.com", "user_id": 1 } }
Fields:
txid
: transaction at which the record was last updated (required)current_xmin
:txid_snapshot_xmin(txid_snapshot_current())
(required)since
: min oftxid_snapshot_xmin(txid_current_snapshot())
andtxid
(required)deleted
: whether or not the row is marked as deleteddata
: any data fields in the row not part of the lockstep protocol
-
snapshot_completed
(when the initial dump/snapshot is complete){ "control": true, "type": "snapshot_completed", "timestamp": 123456789 }
-
heartbeat
(after each set of updates is sent out or when there are no rows in lastn
seconds){ "control": true, "type": "heartbeat", "timestamp": 123456789 }
Tests are good. To run them, you need to have a postgres server running locally
with a database named gls_test
:
$ createdb gls_test
The test database URL is currently hardcoded as postgres://localhost:5432/gls_test
with no authentication and no SSL. Once you have that set up, you can run the tests:
$ go test
warning: building out-of-date packages:
gls/logger
installing these packages with 'go test -i' will speed future tests.
PASS
ok gls 0.119s