Expose the appVersion via the VersionCheck healthcheck

This commit is contained in:
R. Tyler Croy 2016-12-18 11:45:23 -08:00
parent 3329b6f475
commit 2822beb0f5
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
2 changed files with 9 additions and 2 deletions

View File

@ -36,7 +36,7 @@ class HttpWizard extends Application<HttpWizardConfiguration> {
@Override
void run(HttpWizardConfiguration configuration,
Environment env) {
env.healthChecks().register('sanity', new VersionCheck());
env.healthChecks().register('sanity', new VersionCheck(configuration));
}
@Override

View File

@ -18,6 +18,8 @@
package io.lasagna.httpwizard.checks
import io.lasagna.httpwizard.HttpWizardConfiguration
import com.codahale.metrics.health.HealthCheck
import com.codahale.metrics.health.HealthCheck.Result
@ -25,9 +27,14 @@ import com.codahale.metrics.health.HealthCheck.Result
* VersionCheck simple dumps the version of the running application
*/
class VersionCheck extends HealthCheck {
protected HttpWizardConfiguration config
VersionCheck(HttpWizardConfiguration c) {
this.config = c
}
@Override
protected Result check() throws Exception {
return Result.healthy()
return Result.healthy(this.config.appVersion)
}
}