Skip to content

Commit

Permalink
add support CoskyReactiveDiscoveryClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang committed Jun 10, 2021
1 parent 16b4154 commit 42f5ee4
Show file tree
Hide file tree
Showing 22 changed files with 206 additions and 71 deletions.
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
*[CoSky](https://github.com/Ahoo-Wang/CoSky)* is a lightweight, low-cost service registration, service discovery, and configuration service SDK. By using
Redis in the existing infrastructure (I believe you have already deployed Redis), it doesn’t need to bring extra to the
operation and maintenance deployment. Cost and burden. With the high performance of Redis, *CoSky*
provides ultra-high TPS&QPS (100,000+/s [JMH Benchmark](#jmh-benchmark)). *CoSky* combines the process cache strategy + *
Redis PubSub* to achieve real-time process cache refresh, with unparalleled QPS performance (70,000,000+/s [JMH Benchmark](#jmh-benchmark)) and real-time consistency
provides ultra-high TPS&QPS (100,000+/s [JMH Benchmark](#jmh-benchmark)). *CoSky* combines the process cache strategy + *Redis PubSub* to achieve real-time process cache refresh, with unparalleled QPS performance (70,000,000+/s [JMH Benchmark](#jmh-benchmark)) and real-time consistency
between process cache and Redis.

### Service Discovery
Expand All @@ -35,7 +34,7 @@ between process cache and Redis.
> Kotlin DSL
``` kotlin
val coskyVersion = "1.1.5";
val coskyVersion = "1.1.6";
implementation("me.ahoo.cosky:spring-cloud-starter-cosky-config:${coskyVersion}")
implementation("me.ahoo.cosky:spring-cloud-starter-cosky-discovery:${coskyVersion}")
```
Expand All @@ -52,7 +51,7 @@ between process cache and Redis.
<modelVersion>4.0.0</modelVersion>
<artifactId>demo</artifactId>
<properties>
<cosky.version>1.1.5</cosky.version>
<cosky.version>1.1.6</cosky.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -96,30 +95,30 @@ logging:
#### Option 1:Download the executable file
> Download [cosky-rest-api-server](https://github.com/Ahoo-Wang/cosky/releases/download/1.1.5/cosky-rest-api-1.1.5.tar)
> Download [cosky-rest-api-server](https://github.com/Ahoo-Wang/cosky/releases/download/1.1.6/cosky-rest-api-1.1.6.tar)
> tar *cosky-rest-api-1.1.5.tar*
> tar *cosky-rest-api-1.1.6.tar*
```shell
cd cosky-rest-api-1.1.5
# Working directory: cosky-rest-api-1.1.5
cd cosky-rest-api-1.1.6
# Working directory: cosky-rest-api-1.1.6
bin/cosky-rest-api --server.port=8080 --cosky.redis.uri=redis://localhost:6379
```

#### Option 2:Run On Docker

```shell
docker pull ahoowang/cosky-rest-api:1.1.5
docker run --name cosky-rest-api -d -p 8080:8080 --link redis -e COSKY_REDIS_URI=redis://redis:6379 ahoowang/cosky-rest-api:1.1.5
docker pull ahoowang/cosky-rest-api:1.1.6
docker run --name cosky-rest-api -d -p 8080:8080 --link redis -e COSKY_REDIS_URI=redis://redis:6379 ahoowang/cosky-rest-api:1.1.6
```

##### MacBook Pro (M1)

> Please use *ahoowang/cosky-rest-api:1.1.5-armv7*
> Please use *ahoowang/cosky-rest-api:1.1.6-armv7*
```shell
docker pull ahoowang/cosky-rest-api:1.1.5-armv7
docker run --name cosky-rest-api -d -p 8080:8080 --link redis -e COSKY_REDIS_URI=redis://redis:6379 ahoowang/cosky-rest-api:1.1.5-armv7
docker pull ahoowang/cosky-rest-api:1.1.6-armv7
docker run --name cosky-rest-api -d -p 8080:8080 --link redis -e COSKY_REDIS_URI=redis://redis:6379 ahoowang/cosky-rest-api:1.1.6-armv7
```

#### Option 3:Run On Kubernetes
Expand Down Expand Up @@ -147,7 +146,7 @@ spec:
value: standalone
- name: COSKY_REDIS_URI
value: redis://redis-uri:6379
image: ahoowang/cosky-rest-api:1.1.5
image: ahoowang/cosky-rest-api:1.1.6
name: cosky-rest-api
ports:
- containerPort: 8080
Expand Down Expand Up @@ -281,12 +280,12 @@ spec:
``` shell
gradle cosky-config:jmh
# or
java -jar cosky-config/build/libs/cosky-config-1.1.5-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
java -jar cosky-config/build/libs/cosky-config-1.1.6-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
```

```
# JMH version: 1.29
# VM version: JDK 11.1.51, OpenJDK 64-Bit Server VM, 11.1.51+9-LTS
# VM version: JDK 11.1.61, OpenJDK 64-Bit Server VM, 11.1.61+9-LTS
# VM invoker: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/Users/ahoo/cosky/cosky-config/build/tmp/jmh -Duser.country=CN -Duser.language=zh -Duser.variant
# Blackhole mode: full + dont-inline hint
Expand All @@ -307,12 +306,12 @@ RedisConfigServiceBenchmark.setConfig thrpt 103659.132
``` shell
gradle cosky-discovery:jmh
# or
java -jar cosky-discovery/build/libs/cosky-discovery-1.1.5-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
java -jar cosky-discovery/build/libs/cosky-discovery-1.1.6-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
```

```
# JMH version: 1.29
# VM version: JDK 11.1.51, OpenJDK 64-Bit Server VM, 11.1.51+9-LTS
# VM version: JDK 11.1.61, OpenJDK 64-Bit Server VM, 11.1.61+9-LTS
# VM invoker: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/Users/ahoo/cosky/cosky-discovery/build/tmp/jmh -Duser.country=CN -Duser.language=zh -Duser.variant
# Blackhole mode: full + dont-inline hint
Expand Down
32 changes: 16 additions & 16 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
> Kotlin DSL
``` kotlin
val coskyVersion = "1.1.5";
val coskyVersion = "1.1.6";
implementation("me.ahoo.cosky:spring-cloud-starter-cosky-config:${coskyVersion}")
implementation("me.ahoo.cosky:spring-cloud-starter-cosky-discovery:${coskyVersion}")
```
Expand All @@ -46,7 +46,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>demo</artifactId>
<properties>
<cosky.version>1.1.5</cosky.version>
<cosky.version>1.1.6</cosky.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -90,30 +90,30 @@ logging:
#### 方式一:下载可执行文件
> 下载 [rest-api-server](https://github.com/Ahoo-Wang/cosky/releases/download/1.1.5/cosky-rest-api-1.1.5.tar)
> 下载 [rest-api-server](https://github.com/Ahoo-Wang/cosky/releases/download/1.1.6/cosky-rest-api-1.1.6.tar)
> 解压 *cosky-rest-api-1.1.5.tar*
> 解压 *cosky-rest-api-1.1.6.tar*
```shell
cd cosky-rest-api-1.1.5
# 工作目录: cosky-rest-api-1.1.5
cd cosky-rest-api-1.1.6
# 工作目录: cosky-rest-api-1.1.6
bin/cosky-rest-api --server.port=8080 --cosky.redis.uri=redis://localhost:6379
```

#### 方式二:在 Docker 中运行

```shell
docker pull ahoowang/cosky-rest-api:1.1.5
docker run --name cosky-rest-api -d -p 8080:8080 --link redis -e COSKY_REDIS_URI=redis://redis:6379 ahoowang/cosky-rest-api:1.1.5
docker pull ahoowang/cosky-rest-api:1.1.6
docker run --name cosky-rest-api -d -p 8080:8080 --link redis -e COSKY_REDIS_URI=redis://redis:6379 ahoowang/cosky-rest-api:1.1.6
```

##### MacBook Pro (M1)

> 请使用 *ahoowang/cosky-rest-api:1.1.5-armv7*
> 请使用 *ahoowang/cosky-rest-api:1.1.6-armv7*
```shell
docker pull ahoowang/cosky-rest-api:1.1.5-armv7
docker run --name cosky-rest-api -d -p 8080:8080 --link redis -e COSKY_REDIS_URI=redis://redis:6379 ahoowang/cosky-rest-api:1.1.5-armv7
docker pull ahoowang/cosky-rest-api:1.1.6-armv7
docker run --name cosky-rest-api -d -p 8080:8080 --link redis -e COSKY_REDIS_URI=redis://redis:6379 ahoowang/cosky-rest-api:1.1.6-armv7
```

#### 方式三:在 Kubernetes 中运行
Expand Down Expand Up @@ -141,7 +141,7 @@ spec:
value: standalone
- name: COSKY_REDIS_URI
value: redis://redis-uri:6379
image: ahoowang/cosky-rest-api:1.1.5
image: ahoowang/cosky-rest-api:1.1.6
name: cosky-rest-api
ports:
- containerPort: 8080
Expand Down Expand Up @@ -275,12 +275,12 @@ spec:
``` shell
gradle cosky-config:jmh
# or
java -jar cosky-config/build/libs/cosky-config-1.1.5-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
java -jar cosky-config/build/libs/cosky-config-1.1.6-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
```

```
# JMH version: 1.29
# VM version: JDK 11.1.51, OpenJDK 64-Bit Server VM, 11.1.51+9-LTS
# VM version: JDK 11.1.61, OpenJDK 64-Bit Server VM, 11.1.61+9-LTS
# VM invoker: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/Users/ahoo/cosky/config/build/tmp/jmh -Duser.country=CN -Duser.language=zh -Duser.variant
# Blackhole mode: full + dont-inline hint
Expand All @@ -301,12 +301,12 @@ RedisConfigServiceBenchmark.setConfig thrpt 103659.132
``` shell
gradle cosky-discovery:jmh
# or
java -jar cosky-discovery/build/libs/cosky-discovery-1.1.5-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
java -jar cosky-discovery/build/libs/cosky-discovery-1.1.6-jmh.jar -bm thrpt -t 25 -wi 1 -rf json -f 1
```

```
# JMH version: 1.29
# VM version: JDK 11.1.51, OpenJDK 64-Bit Server VM, 11.1.51+9-LTS
# VM version: JDK 11.1.61, OpenJDK 64-Bit Server VM, 11.1.61+9-LTS
# VM invoker: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
# VM options: -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/Users/ahoo/cosky/discovery/build/tmp/jmh -Duser.country=CN -Duser.language=zh -Duser.variant
# Blackhole mode: full + dont-inline hint
Expand Down
11 changes: 8 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ val coreProjects = listOf(
val restApiProject = project(":cosky-rest-api")
val mirrorProject = project(":cosky-mirror")
val serverProjects = listOf(restApiProject, mirrorProject)
val publishProjects = subprojects - serverProjects
val exampleProjects = listOf(
project(":cosky-service-provider"),
project(":cosky-service-provider-api"),
project(":cosky-service-consumer")
)
val publishProjects = subprojects - serverProjects - exampleProjects
val libraryProjects = publishProjects - bomProjects

ext {
set("lombokVersion", "1.18.20")
set("springBootVersion", "2.4.5")
set("springCloudVersion", "2020.0.2")
set("springBootVersion", "2.4.6")
set("springCloudVersion", "2020.0.3")
set("jmhVersion", "1.29")
set("guavaVersion", "30.0-jre")
set("springfoxVersion", "3.0.0")
Expand Down
2 changes: 1 addition & 1 deletion examples/cosky-service-consumer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

dependencies {
implementation(project(":examples:cosky-service-provider-api"))
implementation(project(":cosky-service-provider-api"))

implementation(platform(project(":cosky-dependencies")))
implementation("io.springfox:springfox-boot-starter")
Expand Down
7 changes: 6 additions & 1 deletion examples/cosky-service-provider-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
plugins {
`java-library`
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
dependencies {
implementation(platform(project(":cosky-dependencies")))
api("org.springframework.cloud:spring-cloud-openfeign-core")
}
2 changes: 1 addition & 1 deletion examples/cosky-service-provider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

dependencies {
implementation(project(":examples:cosky-service-provider-api"))
implementation(project(":cosky-service-provider-api"))

implementation(platform(project(":cosky-dependencies")))
implementation("io.springfox:springfox-boot-starter")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=me.ahoo.cosky
version=1.1.5
version=1.1.6

description=CoSky On Redis (Service Discovery and Configuration Service)
website=https://github.com/Ahoo-Wang/cosky
Expand Down
2 changes: 1 addition & 1 deletion k8s/deployment/cosky-mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
value: nacos
- name: SPRING_CLOUD_NACOS_PASSWORD
value: nacos-pwd
image: ahoowang/cosky-mirror:1.1.5
image: ahoowang/cosky-mirror:1.1.6
name: cosky-mirror
resources:
limits:
Expand Down
2 changes: 1 addition & 1 deletion k8s/deployment/cosky-rest-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
value: standalone
- name: COSKY_REDIS_URI
value: redis://redis-uri:6379
image: ahoowang/cosky-rest-api:1.1.5
image: ahoowang/cosky-rest-api:1.1.6
name: cosky-rest-api
ports:
- containerPort: 8080
Expand Down
6 changes: 3 additions & 3 deletions k8s/docker/cosky-mirror/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# docker buildx build --push --platform linux/arm/v7 --build-arg COSKY_VERSION=1.1.5 --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.11_9-slim -t ahoowang/cosky-mirror:1.1.5-armv7 .
# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg COSKY_VERSION=1.1.5 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/cosky-mirror:1.1.5 .
# docker buildx build --push --platform linux/arm/v7 --build-arg COSKY_VERSION=1.1.6 --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.11_9-slim -t ahoowang/cosky-mirror:1.1.6-armv7 .
# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg COSKY_VERSION=1.1.6 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/cosky-mirror:1.1.6 .

ARG JDK_VERSION=jdk11u-centos-nightly-slim
ARG COSKY_VERSION=1.1.5
ARG COSKY_VERSION=1.1.6
ARG COSKY_HOME=/cosky
FROM adoptopenjdk/openjdk11:${JDK_VERSION} AS base

Expand Down
6 changes: 3 additions & 3 deletions k8s/docker/rest-api-local/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# docker buildx build --push --platform linux/arm/v7 --build-arg COSKY_VERSION=1.1.5 --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.11_9-slim -t ahoowang/cosky-rest-api:1.1.5-armv7 .
# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg COSKY_VERSION=1.1.5 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/cosky-rest-api:1.1.5 .
# docker buildx build --push --platform linux/arm/v7 --build-arg COSKY_VERSION=1.1.6 --build-arg JDK_VERSION=armv7l-centos-jdk-11.0.11_9-slim -t ahoowang/cosky-rest-api:1.1.6-armv7 .
# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg COSKY_VERSION=1.1.6 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/cosky-rest-api:1.1.6 .

ARG JDK_VERSION=jdk11u-centos-nightly-slim
ARG COSKY_VERSION=1.1.5
ARG COSKY_VERSION=1.1.6
ARG COSKY_HOME=/cosky
FROM adoptopenjdk/openjdk11:${JDK_VERSION} AS base

Expand Down
6 changes: 3 additions & 3 deletions k8s/docker/rest-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# docker buildx build --push --platform linux/arm/v7 --build-arg COSKY_VERSION=1.1.5 --build-arg JDK_VERSION=armv7l-centos-jdk-11.1.51_9-slim -t ahoowang/cosky-rest-api:1.1.5-armv7 .
# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg COSKY_VERSION=1.1.5 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/cosky-rest-api:1.1.5 .
# docker buildx build --push --platform linux/arm/v7 --build-arg COSKY_VERSION=1.1.6 --build-arg JDK_VERSION=armv7l-centos-jdk-11.1.61_9-slim -t ahoowang/cosky-rest-api:1.1.6-armv7 .
# docker buildx build --push --platform linux/amd64,linux/arm64 --build-arg COSKY_VERSION=1.1.6 --build-arg JDK_VERSION=jdk11u-centos-nightly-slim -t ahoowang/cosky-rest-api:1.1.6 .

ARG JDK_VERSION=jdk11u-centos-nightly-slim
ARG COSKY_VERSION=1.1.5
ARG COSKY_VERSION=1.1.6
ARG COSKY_HOME=/cosky
FROM adoptopenjdk/openjdk11:${JDK_VERSION} AS base

Expand Down
12 changes: 6 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ buildscript {
}
}

include("examples:cosky-service-provider")
findProject(":examples:cosky-service-provider")?.name = "cosky-service-provider"
include(":cosky-service-provider")
project(":cosky-service-provider").projectDir = file("examples/cosky-service-provider")

include("examples:cosky-service-provider-api")
findProject(":examples:cosky-service-provider-api")?.name = "cosky-service-provider-api"
include(":cosky-service-provider-api")
project(":cosky-service-provider-api").projectDir = file("examples/cosky-service-provider-api")

include("examples:cosky-service-consumer")
findProject(":examples:cosky-service-consumer")?.name = "cosky-service-consumer"
include(":cosky-service-consumer")
project(":cosky-service-consumer").projectDir = file("examples/cosky-service-consumer")
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@ConditionalOnProperty(value = "ribbon.cosky.enabled", matchIfMissing = true)
@ConditionalOnProperty(value = "spring.cloud.cosky.ribbon.enabled", matchIfMissing = true)
public @interface ConditionalOnCoskyRibbon {
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private List<CoskyServer> getCoskyServers() {
if (instances.isEmpty()) {
Collections.emptyList();
}
return instances.stream().map(instance -> new CoskyServer(instance)).collect(Collectors.toList());
return instances.stream().map(CoskyServer::new).collect(Collectors.toList());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@ConditionalOnDiscoveryEnabled
@EnableConfigurationProperties({CoskyDiscoveryProperties.class})
@AutoConfigureAfter(CoskyAutoConfiguration.class)
@AutoConfigureBefore({CommonsClientAutoConfiguration.class})
public class CoskyDiscoveryAutoConfiguration {

@Bean
Expand Down Expand Up @@ -56,16 +55,10 @@ public RedisServiceStatistic redisServiceStatistic(
return new RedisServiceStatistic(redisCommands, messageListenable);
}

@Bean
@ConditionalOnMissingBean
public CoskyDiscoveryClient governDiscoveryClient(
ServiceDiscovery serviceDiscovery, CoskyDiscoveryProperties governDiscoveryProperties) {
return new CoskyDiscoveryClient(serviceDiscovery, governDiscoveryProperties);
}

@Bean
@ConditionalOnMissingBean
public LoadBalancer loadBalancer(
public LoadBalancer coskyLoadBalancer(
ConsistencyRedisServiceDiscovery serviceDiscovery) {
return new BinaryWeightRandomLoadBalancer(serviceDiscovery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public CoskyDiscoveryClient(ServiceDiscovery serviceDiscovery, CoskyDiscoveryPro
*/
@Override
public String description() {
return "Govern Service Discovery Client On Redis";
return "CoSky Discovery Client";
}

/**
Expand Down
Loading

0 comments on commit 42f5ee4

Please sign in to comment.