Skip to content

Add event stream#401

Merged
benbjohnson merged 1 commit intomainfrom
events
Sep 6, 2023
Merged

Add event stream#401
benbjohnson merged 1 commit intomainfrom
events

Conversation

@benbjohnson
Copy link
Collaborator

@benbjohnson benbjohnson commented Sep 6, 2023

This pull request implements the GET /events endpoint which provides a newline-delimited stream of JSON objects. Currently, it implements 3 types of events: init, tx, & primaryChange.

/cc @tantaman

TODO

Event Types

init

The init event is currently identical to the primaryChange event in that it shows information about this primary status. It is always the first event published.

{
    "type": "init",
    "data":
    {
        "isPrimary": true,
        "hostname": "myPrimaryHost"
    }
}

tx

The tx event is published every time a new LTX is written by the node or is received and applied from the primary.

{
    "type": "tx",
    "db": "db",
    "data":
    {
        "txID": "0000000000000027",
        "postApplyChecksum": "83b05248774ce767",
        "pageSize": 4096,
        "commit": 2,
        "timestamp": "2023-09-06T19:12:34.985Z"
    }
}

primaryChange

The primaryChange event shows information about this primary status. It is delivered when the node becomes primary, loses primary status, connects to a primary, or loses its connection to the primary.

{
    "type": "init",
    "data":
    {
        "isPrimary": true,
        "hostname": "myPrimaryHost"
    }
}

Usage

$ curl localhost:20202/events
{"type":"init","data":{"isPrimary":true}}
{"type":"tx","db":"db","data":{"txID":"0000000000000027","postApplyChecksum":"83b05248774ce767","pageSize":4096,"commit":2,"timestamp":"2023-09-06T19:12:34.985Z"}}
{"type":"tx","db":"db","data":{"txID":"0000000000000028","postApplyChecksum":"8467267f644a1b66","pageSize":4096,"commit":2,"timestamp":"2023-09-06T19:12:39.586Z"}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant