-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add index build state as readiness check indicator (#6700)
#### What type of PR is this? /kind improvement /area core /milestone 2.20.x #### What this PR does / why we need it: 将索引构建状态添加到就绪检测的指标中 #### Which issue(s) this PR fixes: Fixes #6632 #### Does this PR introduce a user-facing change? ```release-note 将索引构建状态添加到就绪检测的指标中以优化就绪时访问出现索引不可用的问题 ```
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 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
8 changes: 8 additions & 0 deletions
8
application/src/main/java/run/halo/app/extension/availability/IndexBuildState.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,8 @@ | ||
package run.halo.app.extension.availability; | ||
|
||
import org.springframework.boot.availability.AvailabilityState; | ||
|
||
public enum IndexBuildState implements AvailabilityState { | ||
BUILDING, | ||
BUILT; | ||
} |
22 changes: 22 additions & 0 deletions
22
...ion/src/main/java/run/halo/app/extension/availability/IndexBuildStateHealthIndicator.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,22 @@ | ||
package run.halo.app.extension.availability; | ||
|
||
import org.springframework.boot.actuate.availability.AvailabilityStateHealthIndicator; | ||
import org.springframework.boot.actuate.health.Status; | ||
import org.springframework.boot.availability.ApplicationAvailability; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class IndexBuildStateHealthIndicator extends AvailabilityStateHealthIndicator { | ||
/** | ||
* Create a {@link IndexBuildStateHealthIndicator} instance by {@link ApplicationAvailability}. | ||
* Mapping {@link IndexBuildState} to {@link Status}. | ||
* | ||
* @see IndexBuildState | ||
*/ | ||
public IndexBuildStateHealthIndicator(ApplicationAvailability availability) { | ||
super(availability, IndexBuildState.class, (statusMappings) -> { | ||
statusMappings.add(IndexBuildState.BUILT, Status.UP); | ||
statusMappings.add(IndexBuildState.BUILDING, Status.OUT_OF_SERVICE); | ||
}); | ||
} | ||
} |