-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Health Check for Azure App Configuration (#22949)
* Added Health Check * Removed unneeded check * Fixed names, tests, and review comments. * Updated nit
- Loading branch information
Showing
9 changed files
with
233 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...g/src/main/java/com/azure/spring/cloud/config/health/AppConfigurationHealthIndicator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.spring.cloud.config.health; | ||
|
||
import org.springframework.boot.actuate.health.Health; | ||
import org.springframework.boot.actuate.health.HealthIndicator; | ||
|
||
import com.azure.spring.cloud.config.AppConfigurationRefresh; | ||
|
||
/** | ||
* Indicator class of App Configuration | ||
*/ | ||
public class AppConfigurationHealthIndicator implements HealthIndicator { | ||
|
||
private final AppConfigurationRefresh refresh; | ||
|
||
public AppConfigurationHealthIndicator(AppConfigurationRefresh refresh) { | ||
this.refresh = refresh; | ||
} | ||
|
||
@Override | ||
public Health health() { | ||
Health.Builder healthBuilder = new Health.Builder(); | ||
Boolean healthy = true; | ||
|
||
for (String store : refresh.getAppConfigurationStoresHealth().keySet()) { | ||
if (AppConfigurationStoreHealth.DOWN.equals(refresh.getAppConfigurationStoresHealth().get(store))) { | ||
healthy = false; | ||
healthBuilder.withDetail(store, "DOWN"); | ||
} else if (refresh.getAppConfigurationStoresHealth().get(store).equals(AppConfigurationStoreHealth.NOT_LOADED)) { | ||
healthBuilder.withDetail(store, "NOT LOADED"); | ||
} else { | ||
healthBuilder.withDetail(store, "UP"); | ||
} | ||
} | ||
|
||
if (!healthy) { | ||
return healthBuilder.down().build(); | ||
} | ||
return healthBuilder.up().build(); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...onfig/src/main/java/com/azure/spring/cloud/config/health/AppConfigurationStoreHealth.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.spring.cloud.config.health; | ||
|
||
/** | ||
* App Configuration Health states | ||
*/ | ||
public enum AppConfigurationStoreHealth { | ||
|
||
UP, | ||
DOWN, | ||
NOT_LOADED | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...configuration-config/src/main/java/com/azure/spring/cloud/config/health/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
/** | ||
* Package contains classes for converting Azure App Configuration Health information. | ||
*/ | ||
package com.azure.spring.cloud.config.health; |
Oops, something went wrong.