自定义Endpoint
用户可以自己定义
Endpoint
实现定制化的健康检查接口eg
@Endpoint(id = "appId")
public class AppIdEndpoint {
@ReadOperation
public String appId() {
return "esa-restlight";
}
}
上面的代码自定义了一个Endpoint
接口并返回appid
将上面接口注入Spring容器
@Bean
public AppIdEndpoint endpoint() {
return new AppIdEndpoint();
}
启动之后访问curl -X GET localhost:8080/actuator/appId
返回
esa-restlight
自定义异步EndPoint
用户可以自己定义基于Completablefture
的Endpoint
实现定制化的健康检查接口
eg
@Endpoint(id = "appId")
public class AppIdEndpoint {
@ReadOperation
public CompletableFuture<String> appId() {
return CompletableFuture.supplyAsync(() -> {
// do something...
return "esa-restlight";
});
}
}
上面的代码自定义了一个异步的Endpoint
接口并返回appid
将上面接口注入Spring容器
@Bean
public AppIdEndpoint endpoint() {
return new AppIdEndpoint();
}
启动之后访问curl -X GET localhost:8080/actuator/appId
返回
esa-restlight
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified July 28, 2022: refactor main docs to v0.1.1 (#199) (8423db1)