instatushq / out

Monitor services in your menu bar
https://instatus.com/out
MIT License
163 stars 14 forks source link

Bitwarden and Hund-based services #28

Closed franky47 closed 3 years ago

franky47 commented 3 years ago

I use Bitwarden as my password manager. Their status page is powered by Hund, which unfortunately does not seem to have a simple JSON endpoint to ping for updates, but instead uses a live event stream of Server-Sent Events.

In order to obtain the status from Hund-based services, there could be a few approaches:

Approach A: following the SSE protocol

  1. Open a long-running connection in the Service constructor
  2. Listen to events with status updates
  3. Cache the latest state from those events
  4. Return the latest cached value in updateStatus

Pros:

Cons:

Approach B: polling

  1. Open a connection in updateStatus
  2. Wait for it to return the current status for the service
  3. Kill the connection (as it will not terminate on its own)
  4. Parse and return the current status

Pros:

Cons:

alisalahio commented 3 years ago

Hi @franky47,

Thank you so much for the research you've done! 🔥

I personally prefer Approach B as:

I'm OK with both approaches though.. If you're planning to implement this, feel free to go ahead with whatever you prefer 🚀

franky47 commented 3 years ago

Note that the 5 minutes are the maximum time between "nothing changed" updates. I supposed (but haven't checked) that failures are reported in real time, in which case they'd be caught within the 5 seconds (max) of Out's polling.

alisalahio commented 3 years ago

Oh Ok that's awesome :D let's try either approach then :D

franky47 commented 3 years ago

After leaving a connection open for a while, I did not get anymore status updates, so I guess solution B is indeed better, as this way we're sure not to miss anything. I'll see how I can kill the connection after the initial state is received, hopefully that can be done without adding extra dependencies.

franky47 commented 3 years ago

Note: EventSource may not be the wisest choice for long-term maintenance, as it shows some lack of interest by the Chrome team and w3c. Examples include the inability to pass headers to the underlying request (which will be the subject of an upcoming PR): https://github.com/whatwg/html/issues/2177