Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event stream #401

Merged
merged 1 commit into from
Sep 6, 2023
Merged

Add event stream #401

merged 1 commit into from
Sep 6, 2023

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