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

feature: streaming checks #80

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nbgraham
Copy link

@nbgraham nbgraham commented Feb 2, 2024

I recognize that this is a big change and may not be accepted, but wanted to get the idea out there. I'm pretty sure it's not a breaking change though.

I started looking at using this library with gRPC health checks but couldn't figure out how to utilize the stream option where the server pushes status updates.

So I made this PR as an example of "streaming" check: a check that listens for updates on a go channel (dependency pushes health check updates instead of this app pulling them).

This "streaming" check is a more generic form of the periodic check. So I implemented the periodic check as a streaming check internally.
A streaming check could be built upon for extremely custom async checks like

  • while healthy, check every x seconds
  • on first fail, check more frequently on exponential backoff

Other tweaks

  • made separate, read-write mutexs. This might be more performance but mostly for clarity.
  • allow setting the root context of the async checks

Comments

  • a periodic check with a period of 0 was literally indistinguishable in code from a sync check. I found this really confusing when working with the unit tests. With this PR, that is no longer true.

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.

None yet

1 participant