diff --git a/README.md b/README.md index 2ff2d9d2..7d097987 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ process cache refresh, with unparalleled QPS performance and real-time consisten > Kotlin DSL ``` kotlin - val governVersion = "0.9.2"; + val governVersion = "0.9.3"; implementation("me.ahoo.govern:spring-cloud-starter-config:${governVersion}") implementation("me.ahoo.govern:spring-cloud-starter-discovery:${governVersion}") ``` @@ -32,7 +32,7 @@ process cache refresh, with unparalleled QPS performance and real-time consisten 4.0.0 demo - 0.9.2 + 0.9.3 @@ -67,29 +67,38 @@ spring: url: redis://localhost:6379 ``` -## Dashboard (beta) +## REST-API Server (``Optional``) + +```shell +bin/rest-api +``` + +> http://localhost:8080/ + +### Dashboard -### Namespace +![dashboard-dashboard](./docs/dashboard-dashboard.png) + +#### Namespace ![dashboard-namespace](./docs/dashboard-namespace.png) -### Config +#### Config ![dashboard-config](./docs/dashboard-config.png) +![dashboard-config-edit](./docs/dashboard-config-edit.png) +![dashboard-config-rollback](./docs/dashboard-config-rollback.png) -### Service +#### Service ![dashboard-service](./docs/dashboard-service.png) +![dashboard-service-edit](./docs/dashboard-service-edit.png) -## REST-API Server (``Optional``) - -```shell -bin/rest-api -``` +### REST-API > http://localhost:8080/swagger-ui/index.html#/ -### Namespace +##### Namespace ![rest-api-namespace](./docs/rest-api-namespace.png) @@ -103,7 +112,7 @@ bin/rest-api - /v1/namespaces/current/{namespace} - PUT -### Config +##### Config ![rest-api-config](./docs/rest-api-config.png) @@ -120,7 +129,7 @@ bin/rest-api - /v1/namespaces/{namespace}/configs/{configId}/to/{targetVersion} - PUT -### Service +#### Service ![rest-api-service](./docs/rest-api-service.png) @@ -133,7 +142,7 @@ bin/rest-api - DELETE - /v1/namespaces/{namespace}/services/{serviceId}/instances/{instanceId}/metadata - PUT -- /v1/namespaces/{namespace}/services/lb/{serviceId} +- /v1/namespaces/{namespace}/services/{serviceId}/lb - GET ## JMH Benchmark @@ -192,6 +201,5 @@ RedisServiceRegistryBenchmark.renew thrpt 67116.1 ## TODO -1. Dashboard -2. Import/Export API -3. Grayscale Publishing +1. Import/Export API +2. Grayscale Publishing diff --git a/README.zh-CN.md b/README.zh-CN.md index 439452ac..bd11e7e1 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -10,7 +10,7 @@ Govern Service* 提供了超高TPS&QPS。*Govern Service* 结合本地进程缓 > Kotlin DSL ``` kotlin - val governVersion = "0.9.2"; + val governVersion = "0.9.3"; implementation("me.ahoo.govern:spring-cloud-starter-config:${governVersion}") implementation("me.ahoo.govern:spring-cloud-starter-discovery:${governVersion}") ``` @@ -27,7 +27,7 @@ Govern Service* 提供了超高TPS&QPS。*Govern Service* 结合本地进程缓 4.0.0 demo - 0.9.2 + 0.9.3 @@ -62,29 +62,38 @@ spring: url: redis://localhost:6379 ``` -## 管理平台 (beta) +## REST-API Server (``Optional``) + +```shell +bin/rest-api +``` + +> http://localhost:8080/ + +### Dashboard -### 命名空间管理 +![dashboard-dashboard](./docs/dashboard-dashboard.png) + +#### 命名空间管理 ![dashboard-namespace](./docs/dashboard-namespace.png) -### 配置管理 +#### 配置管理 ![dashboard-config](./docs/dashboard-config.png) +![dashboard-config-edit](./docs/dashboard-config-edit.png) +![dashboard-config-rollback](./docs/dashboard-config-rollback.png) -### 服务管理 +#### 服务管理 ![dashboard-service](./docs/dashboard-service.png) +![dashboard-service-edit](./docs/dashboard-service-edit.png) -## REST-API Server (``Optional``) - -```shell -bin/rest-api -``` +### REST-API > http://localhost:8080/swagger-ui/index.html#/ -### Namespace +##### Namespace ![rest-api-namespace](./docs/rest-api-namespace.png) @@ -98,7 +107,7 @@ bin/rest-api - /v1/namespaces/current/{namespace} - PUT -### Config +##### Config ![rest-api-config](./docs/rest-api-config.png) @@ -115,6 +124,22 @@ bin/rest-api - /v1/namespaces/{namespace}/configs/{configId}/to/{targetVersion} - PUT +#### Service + +![rest-api-service](./docs/rest-api-service.png) + +- /v1/namespaces/{namespace}/services/ + - GET +- /v1/namespaces/{namespace}/services/{serviceId}/instances + - GET + - PUT +- /v1/namespaces/{namespace}/services/{serviceId}/instances/{instanceId} + - DELETE +- /v1/namespaces/{namespace}/services/{serviceId}/instances/{instanceId}/metadata + - PUT +- /v1/namespaces/{namespace}/services/{serviceId}/lb + - GET + ### Service ![rest-api-service](./docs/rest-api-service.png) @@ -187,5 +212,5 @@ RedisServiceRegistryBenchmark.renew thrpt 67116.1 ## TODO -1. Dashboard +1. Import/Export API 2. Grayscale Publishing diff --git a/discovery/src/main/java/me/ahoo/govern/discovery/Instance.java b/discovery/src/main/java/me/ahoo/govern/discovery/Instance.java index 93f5e921..00bf55cb 100644 --- a/discovery/src/main/java/me/ahoo/govern/discovery/Instance.java +++ b/discovery/src/main/java/me/ahoo/govern/discovery/Instance.java @@ -28,7 +28,7 @@ public static URI getUri(Instance instance) { return URI.create(uri); } - public URI getUri() { + public URI parseUri() { return getUri(this); } diff --git a/discovery/src/main/java/me/ahoo/govern/discovery/ServiceInstanceCodec.java b/discovery/src/main/java/me/ahoo/govern/discovery/ServiceInstanceCodec.java index aa131828..121e5aee 100644 --- a/discovery/src/main/java/me/ahoo/govern/discovery/ServiceInstanceCodec.java +++ b/discovery/src/main/java/me/ahoo/govern/discovery/ServiceInstanceCodec.java @@ -43,7 +43,7 @@ public static Map encode(ServiceInstance serviceInstance) { public static String[] encodeMetadata(String[] preArgs, Map instanceMetadata) { if (instanceMetadata.isEmpty()) { - return EMPTY_STRING_ARRAY; + return preArgs; } String[] values = new String[preArgs.length + instanceMetadata.size() * 2]; System.arraycopy(preArgs, 0, values, 0, preArgs.length); diff --git a/discovery/src/main/java/me/ahoo/govern/discovery/ServiceRegistry.java b/discovery/src/main/java/me/ahoo/govern/discovery/ServiceRegistry.java index c7f4ef1d..1be8e564 100644 --- a/discovery/src/main/java/me/ahoo/govern/discovery/ServiceRegistry.java +++ b/discovery/src/main/java/me/ahoo/govern/discovery/ServiceRegistry.java @@ -9,6 +9,11 @@ */ public interface ServiceRegistry { + + CompletableFuture setService(String namespace, String serviceId); + + CompletableFuture removeService(String namespace, String serviceId); + /** * 注册实例 * diff --git a/discovery/src/main/java/me/ahoo/govern/discovery/ServiceStatistic.java b/discovery/src/main/java/me/ahoo/govern/discovery/ServiceStatistic.java index fab90060..253db473 100644 --- a/discovery/src/main/java/me/ahoo/govern/discovery/ServiceStatistic.java +++ b/discovery/src/main/java/me/ahoo/govern/discovery/ServiceStatistic.java @@ -14,4 +14,6 @@ public interface ServiceStatistic { CompletableFuture statService(String namespace, @Nullable String serviceId); CompletableFuture> getServiceStats(String namespace); + + CompletableFuture getInstanceCount(String namespace); } diff --git a/discovery/src/main/java/me/ahoo/govern/discovery/redis/DiscoveryRedisScripts.java b/discovery/src/main/java/me/ahoo/govern/discovery/redis/DiscoveryRedisScripts.java index af1c29c1..4c3ed8fd 100644 --- a/discovery/src/main/java/me/ahoo/govern/discovery/redis/DiscoveryRedisScripts.java +++ b/discovery/src/main/java/me/ahoo/govern/discovery/redis/DiscoveryRedisScripts.java @@ -13,9 +13,12 @@ public final class DiscoveryRedisScripts { public static final String REGISTRY_DEREGISTER = "registry_deregister.lua"; public static final String REGISTRY_RENEW = "registry_renew.lua"; public static final String REGISTRY_SET_METADATA = "registry_set_metadata.lua"; + public static final String REGISTRY_SET_SERVICE = "registry_set_service.lua"; + public static final String REGISTRY_REMOVE_SERVICE = "registry_remove_service.lua"; public static final String DISCOVERY_GET_INSTANCES = "discovery_get_instances.lua"; public static final String DISCOVERY_GET_INSTANCE = "discovery_get_instance.lua"; public static final String DISCOVERY_GET_INSTANCE_TTL = "discovery_get_instance_ttl.lua"; + public static final String INSTANCE_COUNT_STAT = "instance_count_stat.lua"; public static final String SERVICE_STAT = "service_stat.lua"; public static CompletableFuture loadRegistryRegister(RedisScriptingAsyncCommands scriptingCommands) { @@ -34,6 +37,14 @@ public static CompletableFuture loadRegistrySetMetadata(RedisScriptingAs return RedisScripts.loadScript(REGISTRY_SET_METADATA, scriptingCommands); } + public static CompletableFuture loadRegistrySetService(RedisScriptingAsyncCommands scriptingCommands) { + return RedisScripts.loadScript(REGISTRY_SET_SERVICE, scriptingCommands); + } + + public static CompletableFuture loadRegistryRemoveService(RedisScriptingAsyncCommands scriptingCommands) { + return RedisScripts.loadScript(REGISTRY_REMOVE_SERVICE, scriptingCommands); + } + public static CompletableFuture loadDiscoveryGetInstances(RedisScriptingAsyncCommands scriptingCommands) { return RedisScripts.loadScript(DISCOVERY_GET_INSTANCES, scriptingCommands); } @@ -49,4 +60,8 @@ public static CompletableFuture loadDiscoveryGetInstanceTtl(RedisScripti public static CompletableFuture loadServiceStat(RedisScriptingAsyncCommands scriptingCommands) { return RedisScripts.loadScript(SERVICE_STAT, scriptingCommands); } + + public static CompletableFuture loadInstanceCountStat(RedisScriptingAsyncCommands scriptingCommands) { + return RedisScripts.loadScript(INSTANCE_COUNT_STAT, scriptingCommands); + } } diff --git a/discovery/src/main/java/me/ahoo/govern/discovery/redis/RedisServiceRegistry.java b/discovery/src/main/java/me/ahoo/govern/discovery/redis/RedisServiceRegistry.java index 6a738b4a..603b0e5b 100644 --- a/discovery/src/main/java/me/ahoo/govern/discovery/redis/RedisServiceRegistry.java +++ b/discovery/src/main/java/me/ahoo/govern/discovery/redis/RedisServiceRegistry.java @@ -76,6 +76,27 @@ private CompletableFuture register0(String namespace, String scriptSha, return redisFuture.toCompletableFuture(); } + @Override + public CompletableFuture setService(String namespace, String serviceId) { + if (log.isInfoEnabled()) { + log.info("setService - serviceId:[{}] @ namespace:[{}].", serviceId, namespace); + } + + return DiscoveryRedisScripts.loadRegistrySetService(redisCommands) + .thenCompose(sha -> redisCommands.evalsha(sha, ScriptOutputType.BOOLEAN, new String[]{namespace}, serviceId)); + + } + + @Override + public CompletableFuture removeService(String namespace, String serviceId) { + if (log.isInfoEnabled()) { + log.info("removeService - serviceId:[{}] @ namespace:[{}].", serviceId, namespace); + } + + return DiscoveryRedisScripts.loadRegistryRemoveService(redisCommands) + .thenCompose(sha -> redisCommands.evalsha(sha, ScriptOutputType.BOOLEAN, new String[]{namespace}, serviceId)); + } + /** * @param serviceInstance 服务实例 */ diff --git a/discovery/src/main/java/me/ahoo/govern/discovery/redis/RedisServiceStatistic.java b/discovery/src/main/java/me/ahoo/govern/discovery/redis/RedisServiceStatistic.java index eb0f7f41..b93fba88 100644 --- a/discovery/src/main/java/me/ahoo/govern/discovery/redis/RedisServiceStatistic.java +++ b/discovery/src/main/java/me/ahoo/govern/discovery/redis/RedisServiceStatistic.java @@ -87,6 +87,12 @@ public CompletableFuture> getServiceStats(String namespace) { }).collect(Collectors.toList())).toCompletableFuture(); } + @Override + public CompletableFuture getInstanceCount(String namespace) { + return DiscoveryRedisScripts.loadInstanceCountStat(redisCommands). + thenCompose(sha -> redisCommands.evalsha(sha, ScriptOutputType.INTEGER, namespace)); + } + private class InstanceListener implements MessageListener { @Override diff --git a/discovery/src/main/resources/instance_count_stat.lua b/discovery/src/main/resources/instance_count_stat.lua new file mode 100644 index 00000000..1ccfa35f --- /dev/null +++ b/discovery/src/main/resources/instance_count_stat.lua @@ -0,0 +1,22 @@ +local namespace = KEYS[1]; +local serviceIdxKey = namespace .. ":svc_idx"; + +local instanceCount = 0; + +local function getInstanceIdxKey(serviceId) + return namespace .. ":svc_itc_idx:" .. serviceId; +end + +local function statInstance(serviceId) + local instanceIdxKey = getInstanceIdxKey(serviceId); + local servicedInstanceCount = redis.call("scard", instanceIdxKey); + instanceCount = instanceCount + servicedInstanceCount; +end + +local serviceIds = redis.call("smembers", serviceIdxKey); + +for index, serviceId in ipairs(serviceIds) do + statInstance(serviceId) +end + +return instanceCount; diff --git a/discovery/src/main/resources/registry_remove_service.lua b/discovery/src/main/resources/registry_remove_service.lua new file mode 100644 index 00000000..bc8b02a5 --- /dev/null +++ b/discovery/src/main/resources/registry_remove_service.lua @@ -0,0 +1,19 @@ +local namespace = KEYS[1]; +local serviceId = ARGV[1]; + +local serviceIdxKey = namespace .. ":svc_idx"; +local serviceIdxStatKey = namespace .. ":svc_stat"; +local instanceIdxKey = namespace .. ":svc_itc_idx:" .. serviceId; + +local instanceCount = redis.call("scard", instanceIdxKey); +if instanceCount > 0 then + return 0; +end + +local affected = redis.call("srem", serviceIdxKey, serviceId); + +if affected > 0 then + redis.call("hdel", serviceIdxStatKey, serviceId); +end + +return affected; diff --git a/discovery/src/main/resources/registry_set_service.lua b/discovery/src/main/resources/registry_set_service.lua new file mode 100644 index 00000000..30389eec --- /dev/null +++ b/discovery/src/main/resources/registry_set_service.lua @@ -0,0 +1,13 @@ +local namespace = KEYS[1]; +local serviceId = ARGV[1]; + +local serviceIdxKey = namespace .. ":svc_idx"; +local serviceIdxStatKey = namespace .. ":svc_stat"; + +local affected = redis.call("sadd", serviceIdxKey, serviceId); + +if affected > 0 then + redis.call("hset", serviceIdxStatKey, serviceId, 0); +end + +return affected; diff --git a/docker/rest-api/Dockerfile b/docker/rest-api/Dockerfile index 406c075a..75204d35 100644 --- a/docker/rest-api/Dockerfile +++ b/docker/rest-api/Dockerfile @@ -1,6 +1,6 @@ # docker build --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.8_10-slim --build-arg GOVERN_VERSION=0.7.2 -t ahoowang/govern-service:0.7.2 . ARG JDK_VERSION=alpine -ARG GOVERN_VERSION=0.9.2 +ARG GOVERN_VERSION=0.9.3 ARG GOVERN_SERVICE_HOME=/govern-service FROM adoptopenjdk/openjdk11:${JDK_VERSION} AS base diff --git a/docs/dashboard-config-edit.png b/docs/dashboard-config-edit.png new file mode 100644 index 00000000..2a020698 Binary files /dev/null and b/docs/dashboard-config-edit.png differ diff --git a/docs/dashboard-config-rollback.png b/docs/dashboard-config-rollback.png new file mode 100644 index 00000000..530be2f4 Binary files /dev/null and b/docs/dashboard-config-rollback.png differ diff --git a/docs/dashboard-config.png b/docs/dashboard-config.png index 5c690833..870ba4db 100644 Binary files a/docs/dashboard-config.png and b/docs/dashboard-config.png differ diff --git a/docs/dashboard-dashboard.png b/docs/dashboard-dashboard.png new file mode 100644 index 00000000..880f8384 Binary files /dev/null and b/docs/dashboard-dashboard.png differ diff --git a/docs/dashboard-namespace.png b/docs/dashboard-namespace.png index 6db704e0..36ffdc8d 100644 Binary files a/docs/dashboard-namespace.png and b/docs/dashboard-namespace.png differ diff --git a/docs/dashboard-service-edit.png b/docs/dashboard-service-edit.png new file mode 100644 index 00000000..1bb033b5 Binary files /dev/null and b/docs/dashboard-service-edit.png differ diff --git a/docs/dashboard-service.png b/docs/dashboard-service.png index 90a6ab48..83e56d5d 100644 Binary files a/docs/dashboard-service.png and b/docs/dashboard-service.png differ diff --git a/docs/rest-api-service.png b/docs/rest-api-service.png index d9593979..08c4b91b 100644 Binary files a/docs/rest-api-service.png and b/docs/rest-api-service.png differ diff --git a/gradle.properties b/gradle.properties index fdde60f9..f05e63b1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=me.ahoo.govern -version=0.9.2 +version=0.9.3 description=Govern Service On Redis website=/~https://github.com/Ahoo-Wang/govern-service diff --git a/rest-api/src/main/java/me/ahoo/govern/rest/config/DashboardConfig.java b/rest-api/src/main/java/me/ahoo/govern/rest/config/DashboardConfig.java new file mode 100644 index 00000000..78a6613d --- /dev/null +++ b/rest-api/src/main/java/me/ahoo/govern/rest/config/DashboardConfig.java @@ -0,0 +1,26 @@ +package me.ahoo.govern.rest.config; + +import org.springframework.boot.web.server.ErrorPage; +import org.springframework.boot.web.server.ErrorPageRegistrar; +import org.springframework.boot.web.server.ErrorPageRegistry; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +/** + * for Dashboard-UI + * + * @author ahoo wang + */ +@Component +public class DashboardConfig implements ErrorPageRegistrar { + /** + * Register pages as required with the given registry. + * + * @param registry the error page registry + */ + @Override + public void registerErrorPages(ErrorPageRegistry registry) { + ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/index.html"); + registry.addErrorPages(error404Page); + } +} diff --git a/rest-api/src/main/java/me/ahoo/govern/rest/controller/ServiceController.java b/rest-api/src/main/java/me/ahoo/govern/rest/controller/ServiceController.java index 63771dc7..13ceba6c 100644 --- a/rest-api/src/main/java/me/ahoo/govern/rest/controller/ServiceController.java +++ b/rest-api/src/main/java/me/ahoo/govern/rest/controller/ServiceController.java @@ -1,5 +1,6 @@ package me.ahoo.govern.rest.controller; +import lombok.var; import me.ahoo.govern.discovery.*; import me.ahoo.govern.discovery.loadbalancer.LoadBalancer; import me.ahoo.govern.rest.support.RequestPathPrefix; @@ -21,7 +22,10 @@ public class ServiceController { private final ServiceStatistic serviceStatistic; private final LoadBalancer loadBalancer; - public ServiceController(ServiceDiscovery discoveryService, ServiceRegistry serviceRegistry, ServiceStatistic serviceStatistic, LoadBalancer loadBalancer) { + public ServiceController(ServiceRegistry serviceRegistry, + ServiceDiscovery discoveryService, + ServiceStatistic serviceStatistic, + LoadBalancer loadBalancer) { this.discoveryService = discoveryService; this.serviceRegistry = serviceRegistry; this.serviceStatistic = serviceStatistic; @@ -33,6 +37,16 @@ public Set getServices(@PathVariable String namespace) { return discoveryService.getServices(namespace).join(); } + @PutMapping(RequestPathPrefix.SERVICES_SERVICE) + public Boolean setService(@PathVariable String namespace, @PathVariable String serviceId) { + return serviceRegistry.setService(namespace, serviceId).join(); + } + + @DeleteMapping(RequestPathPrefix.SERVICES_SERVICE) + public Boolean removeService(@PathVariable String namespace, @PathVariable String serviceId) { + return serviceRegistry.removeService(namespace, serviceId).join(); + } + @GetMapping(RequestPathPrefix.SERVICES_INSTANCES) public List getInstances(@PathVariable String namespace, @PathVariable String serviceId) { return discoveryService.getInstances(namespace, serviceId).join(); @@ -41,6 +55,8 @@ public List getInstances(@PathVariable String namespace, @PathV @PutMapping(RequestPathPrefix.SERVICES_INSTANCES) public Boolean register(@PathVariable String namespace, @PathVariable String serviceId, @RequestBody ServiceInstance instance) { instance.setServiceId(serviceId); + var instanceId = InstanceIdGenerator.DEFAULT.generate(instance); + instance.setInstanceId(instanceId); return serviceRegistry.register(namespace, instance).join(); } diff --git a/rest-api/src/main/java/me/ahoo/govern/rest/controller/StatController.java b/rest-api/src/main/java/me/ahoo/govern/rest/controller/StatController.java new file mode 100644 index 00000000..6c7ffe4d --- /dev/null +++ b/rest-api/src/main/java/me/ahoo/govern/rest/controller/StatController.java @@ -0,0 +1,42 @@ +package me.ahoo.govern.rest.controller; + +import lombok.var; +import me.ahoo.govern.config.ConfigService; +import me.ahoo.govern.core.NamespaceService; +import me.ahoo.govern.discovery.ServiceDiscovery; +import me.ahoo.govern.discovery.ServiceStatistic; +import me.ahoo.govern.rest.support.RequestPathPrefix; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; + +/** + * @author ahoo wang + */ +@CrossOrigin("*") +@RestController +@RequestMapping(RequestPathPrefix.STAT_PREFIX) +public class StatController { + + private final NamespaceService namespaceService; + private final ServiceDiscovery serviceDiscovery; + private final ConfigService configService; + private final ServiceStatistic serviceStatistic; + + public StatController(NamespaceService namespaceService, ServiceDiscovery serviceDiscovery, ConfigService configService, ServiceStatistic serviceStatistic) { + this.namespaceService = namespaceService; + this.serviceDiscovery = serviceDiscovery; + this.configService = configService; + this.serviceStatistic = serviceStatistic; + } + + @GetMapping + public HashMap getStat(@PathVariable String namespace) { + var stat = new HashMap(6); + stat.put("namespaces", namespaceService.getNamespaces().join().size()); + stat.put("services", serviceDiscovery.getServices(namespace).join().size()); + stat.put("instances", serviceStatistic.getInstanceCount(namespace).join().intValue()); + stat.put("configs", configService.getConfigs(namespace).join().size()); + return stat; + } +} diff --git a/rest-api/src/main/java/me/ahoo/govern/rest/support/RequestPathPrefix.java b/rest-api/src/main/java/me/ahoo/govern/rest/support/RequestPathPrefix.java index 8693fa85..ce190cd6 100644 --- a/rest-api/src/main/java/me/ahoo/govern/rest/support/RequestPathPrefix.java +++ b/rest-api/src/main/java/me/ahoo/govern/rest/support/RequestPathPrefix.java @@ -28,6 +28,12 @@ public interface RequestPathPrefix { */ String NAMESPACES_CURRENT_NAMESPACE = NAMESPACES_CURRENT + "/{namespace}"; //endregion + + /** + * /v1/namespaces/{namespace} + */ + String STAT_PREFIX = NAMESPACES_NAMESPACE_PREFIX + "/stat"; + //region configs /** * /v1/namespaces/{namespace}/configs @@ -60,14 +66,20 @@ public interface RequestPathPrefix { * /v1/namespaces/{namespace}/services/stats */ String SERVICES_STATS = "/stats"; + + /** + * /v1/namespaces/{namespace}/services/{serviceId} + */ + String SERVICES_SERVICE = "/{serviceId}"; + /** - * /v1/namespaces/{namespace}/services/lb/{serviceId} + * /v1/namespaces/{namespace}/services/{serviceId}/lb */ - String SERVICES_LB = "/lb/{serviceId}"; + String SERVICES_LB = SERVICES_SERVICE + "/lb"; /** * /v1/namespaces/{namespace}/services/{serviceId}/instances */ - String SERVICES_INSTANCES = "/{serviceId}/instances"; + String SERVICES_INSTANCES = SERVICES_SERVICE + "/instances"; /** * /v1/namespaces/{namespace}/services/{serviceId}/instances/{instanceId} */ diff --git a/rest-api/src/main/resources/application.yml b/rest-api/src/main/resources/application.yml index c82a1299..8b27afe3 100644 --- a/rest-api/src/main/resources/application.yml +++ b/rest-api/src/main/resources/application.yml @@ -6,4 +6,4 @@ spring: weight: 18 web: resources: - static-locations: file:./rest-api/src/dist/dashboard + static-locations: file:./dashboard/ diff --git a/spring-cloud-starter-discovery/src/main/java/me/ahoo/govern/discovery/spring/cloud/discovery/GovernServiceInstance.java b/spring-cloud-starter-discovery/src/main/java/me/ahoo/govern/discovery/spring/cloud/discovery/GovernServiceInstance.java index 95b00646..77e2d1da 100644 --- a/spring-cloud-starter-discovery/src/main/java/me/ahoo/govern/discovery/spring/cloud/discovery/GovernServiceInstance.java +++ b/spring-cloud-starter-discovery/src/main/java/me/ahoo/govern/discovery/spring/cloud/discovery/GovernServiceInstance.java @@ -60,7 +60,7 @@ public boolean isSecure() { */ @Override public URI getUri() { - return serviceInstance.getUri(); + return serviceInstance.parseUri(); } /** diff --git a/spring-cloud-starter-discovery/src/main/java/me/ahoo/govern/discovery/spring/cloud/registry/GovernRegistration.java b/spring-cloud-starter-discovery/src/main/java/me/ahoo/govern/discovery/spring/cloud/registry/GovernRegistration.java index 39cc7687..e733bb21 100644 --- a/spring-cloud-starter-discovery/src/main/java/me/ahoo/govern/discovery/spring/cloud/registry/GovernRegistration.java +++ b/spring-cloud-starter-discovery/src/main/java/me/ahoo/govern/discovery/spring/cloud/registry/GovernRegistration.java @@ -58,7 +58,7 @@ public boolean isSecure() { */ @Override public URI getUri() { - return serviceInstance.getUri(); + return serviceInstance.parseUri(); } /**