Skip to content

Commit

Permalink
Document new SSE API
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenlj committed Aug 21, 2024
1 parent 0d83db3 commit 094d7c0
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,30 @@ Users should make sure to have alerts to detect when a leader is stuck.
API
---

When running, elector can be queried on the election port to get the name of the current leader.
Elector has two API endpoints on the election port for getting information about the currently elected leader.
The endpoints return the same information, but one is a simple JSON object and the other is a [Server Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) stream.

The object returned looks like this:

```json
{
"name": "pod-name",
"last_update": "timestamp of last update"
}
```

### Original API: `/`

Simple GET with immediate return of the described object.


### SSE API: `/sse`

The SSE API is a stream of server sent events that will send a message whenever there is an update.
Each event will be a JSON object as described above.


### Ports

Default election port is 6060 (override with `--http`).
Metrics are available on port 9090 (override with `--metrics-address`).
Expand All @@ -26,8 +49,8 @@ Probes are available on port 8080 (override with `--probe-address`).
Development
-----------

The integration tests uses envtest to simulate a kubernetes cluster.
Using the `integration_test` target in make will configure envtest for you before running the tests.
Some of the tests uses envtest to simulate a kubernetes cluster.
Using the `test` target in make will configure envtest for you before running the tests.

If you would rather control the setup of envtest yourself, use the setup-envtest command to install and configure envtest.

Expand Down

0 comments on commit 094d7c0

Please sign in to comment.