alexliesenfeld / health

A simple and flexible health check library for Go.
MIT License
774 stars 38 forks source link

feature: streaming checks #80

Open nbgraham opened 7 months ago

nbgraham commented 7 months ago

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

Other tweaks

Comments

alexliesenfeld commented 2 months ago

Thanks for providing this PR!

I think your idea is interesting and code looks fine at a first glance as well. I am not sure at the moment if streaming or gRPC should be supported by this library. The initial codebase was written to support standard HTTP and I think adding streaming or gRPC would require a substantial redesign for a robust implementation.

I'd like to park this PR for now and revisit it if gRPC becomes a thing.