feat: 健康检查适配kubernetes
This commit is contained in:
+23
-13
@@ -13,39 +13,49 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.monitor;
|
package cn.odboy.monitor.controller;
|
||||||
|
|
||||||
import cn.odboy.annotation.AnonymousGetMapping;
|
import cn.odboy.annotation.AnonymousGetMapping;
|
||||||
|
import cn.odboy.monitor.service.HealthCheckPointService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 健康检查接口
|
* 健康检查接口
|
||||||
*
|
|
||||||
* @author odboy
|
|
||||||
* @date 2022-01-06
|
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/health")
|
@RequestMapping("/healthCheck")
|
||||||
@Api(tags = "系统:健康检查接口")
|
@Api(tags = "系统:健康检查接口")
|
||||||
public class HealthCheckController {
|
public class HealthCheckController {
|
||||||
|
@Autowired
|
||||||
|
private HealthCheckPointService healthCheckPointService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 健康检查
|
* 就绪检查
|
||||||
*/
|
*/
|
||||||
@AnonymousGetMapping(value = "/check")
|
@AnonymousGetMapping(value = "/readiness")
|
||||||
public ResponseEntity<?> doCheck() {
|
public ResponseEntity<?> doReadiness() {
|
||||||
return ResponseEntity.ok().build();
|
return healthCheckPointService.doReadiness();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 访问首页提示
|
* 存活检查
|
||||||
*/
|
*/
|
||||||
@AnonymousGetMapping("/")
|
@AnonymousGetMapping(value = "/liveness")
|
||||||
public String index() {
|
public ResponseEntity<?> doLiveness() {
|
||||||
return "success";
|
return healthCheckPointService.doLiveness();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 访问首页提示
|
||||||
|
// */
|
||||||
|
// @AnonymousGetMapping("/")
|
||||||
|
// public String index() {
|
||||||
|
// return "success";
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package cn.odboy.monitor.service;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
public interface HealthCheckPointService {
|
||||||
|
/**
|
||||||
|
* 就绪检查
|
||||||
|
*/
|
||||||
|
ResponseEntity<?> doReadiness();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存活检查
|
||||||
|
*/
|
||||||
|
ResponseEntity<?> doLiveness();
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package cn.odboy;
|
||||||
|
|
||||||
|
import cn.odboy.application.system.service.DictService;
|
||||||
|
import cn.odboy.monitor.service.HealthCheckPointService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class HealthCheckPointer implements HealthCheckPointService {
|
||||||
|
@Autowired
|
||||||
|
private DictService dictService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<?> doReadiness() {
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<?> doLiveness() {
|
||||||
|
return ResponseEntity.ok(dictService.getById(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user