Merge pull request #170 from weihubeats/feature_generic_optimization

generic optimization
pull/171/head
龙台 Long Tai 3 years ago committed by GitHub
commit 9dbdd0703c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,22 +26,22 @@ import static cn.hippo4j.common.constant.Constants.BASE_PATH;
@RequestMapping(BASE_PATH + "/apps") @RequestMapping(BASE_PATH + "/apps")
public class ApplicationController { public class ApplicationController {
private final InstanceRegistry instanceRegistry; private final InstanceRegistry<InstanceInfo> instanceRegistry;
@GetMapping("/{appName}") @GetMapping("/{appName}")
public Result applications(@PathVariable String appName) { public Result<List<Lease<InstanceInfo>>> applications(@PathVariable String appName) {
List<Lease<InstanceInfo>> resultInstanceList = instanceRegistry.listInstance(appName); List<Lease<InstanceInfo>> resultInstanceList = instanceRegistry.listInstance(appName);
return Results.success(resultInstanceList); return Results.success(resultInstanceList);
} }
@PostMapping("/register") @PostMapping("/register")
public Result addInstance(@RequestBody InstanceInfo instanceInfo) { public Result<Void> addInstance(@RequestBody InstanceInfo instanceInfo) {
instanceRegistry.register(instanceInfo); instanceRegistry.register(instanceInfo);
return Results.success(); return Results.success();
} }
@PostMapping("/renew") @PostMapping("/renew")
public Result renew(@RequestBody InstanceInfo.InstanceRenew instanceRenew) { public Result<Void> renew(@RequestBody InstanceInfo.InstanceRenew instanceRenew) {
boolean isSuccess = instanceRegistry.renew(instanceRenew); boolean isSuccess = instanceRegistry.renew(instanceRenew);
if (!isSuccess) { if (!isSuccess) {
log.warn("Not Found (Renew) :: {} - {}", instanceRenew.getAppName(), instanceRenew.getInstanceId()); log.warn("Not Found (Renew) :: {} - {}", instanceRenew.getAppName(), instanceRenew.getInstanceId());
@ -51,7 +51,7 @@ public class ApplicationController {
} }
@PostMapping("/remove") @PostMapping("/remove")
public Result remove(@RequestBody InstanceInfo instanceInfo) { public Result<Void> remove(@RequestBody InstanceInfo instanceInfo) {
instanceRegistry.remove(instanceInfo); instanceRegistry.remove(instanceInfo);
return Results.success(); return Results.success();
} }

Loading…
Cancel
Save