Change HealthCheck to a plugin model #16
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Within Nike, we've been using Prana for a number of internal systems, but we needed a way to run it alongside applications other than web apps, and as such we needed a way to let Prana determine the health of those applications. To do this, we basically replaced the existing HealthCheck implementation with a plugin-based system that includes a default implementation to ensure it is still backwards compatible.
To do this, we pulled out most of the logic from the HealthCheckHandler and now the handler calls into a HealthCheckService. That service uses a ServiceLoader to look through a specific directory (configured via an archaius property) for .jar files that contain an implementation of a new HealthCheck interface. It then bootstraps those implementations and attempts to use them to determine the health of whatever app Prana is paired with. If there are no external implementations found, then the service defaults to using a DefaultHealthCheck which is the same one that Prana used before. This logic is only run the first time the HealthCheck endpoint is hit, and because of the default implementation, it should be completely backwards compatible.
Within Nike we've been using this implementation, and thought it might be a good candidate for Prana. If this is something you guys are interested in, I can also provide you with some documentation that explains pretty clearly how to make a new healthcheck implementation and use it.