Skip to content

Commit

Permalink
feat: support nacos server v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gxcsoccer committed May 7, 2019
1 parent 119231e commit 1ca7188
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ typings/
run
test/fixtures/apps/**/proxy
test/fixtures/apps/**/proxy_class
test/fixtures/apps/**/src
test/fixtures/apps/**/pom.xml
test/fixtures/apps/**/target/
test/fixtures/apps/**/config/apiMeta.json
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ before_install:
- './zookeeper-3.4.6/bin/zkServer.sh start'
- echo $JAVA_HOME
- java -version
- 'wget https://github.com/alibaba/nacos/releases/download/0.5.0/nacos-server-0.5.0.tar.gz'
- 'wget https://github.com/gxcsoccer/PDisk/releases/download/1.0.0/startup.sh'
- 'tar xf nacos-server-0.5.0.tar.gz'
- 'wget https://github.com/alibaba/nacos/releases/download/1.0.0/nacos-server-1.0.0.tar.gz'
- 'wget https://github.com/gxcsoccer/PDisk/releases/download/1.0.1/startup.sh'
- 'tar xf nacos-server-1.0.0.tar.gz'
- 'mv ./startup.sh ./nacos/bin/startup.sh'
- 'chmod 755 ./nacos/bin/startup.sh'
- 'nohup ./nacos/bin/startup.sh -m standalone 2>&1 &'
- 'sleep 30'
- 'curl "127.0.0.1:8848/nacos/v1/ns/api/hello"'
- 'cat nohup.out'
- 'curl "127.0.0.1:8848/nacos/v1/ns/operator/metrics"'
install:
- npm i
script:
Expand Down
14 changes: 10 additions & 4 deletions lib/registry/nacos.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ class NacosRegistryClient extends SdkBase {
assert(config.url, '[NacosRegistry] register(config) config.url is required');
const serviceName = this._buildProviderPath(config);
const url = new URL(config.url);
await this._client.deregisterInstance(serviceName, url.hostname, Number(url.port));
await this._client.deregisterInstance(serviceName, {
ip: url.hostname,
port: Number(url.port),
});
}

async _doSubscribe(consumerKey, config) {
this._subscribeMap.set(consumerKey, null);
await this._client.registerInstance(consumerKey, localIp, 0);
await this._client.registerInstance(consumerKey, {
ip: localIp,
port: 0,
});
const providerKey = this._buildProviderPath(config);
this._client.subscribe(providerKey, hosts => {
const addressList = hosts.filter(host => host.enabled).map(host => {
Expand Down Expand Up @@ -145,8 +151,8 @@ class NacosRegistryClient extends SdkBase {
return serviceName;
}

close() {
this._client.close();
async _close() {
await this._client.close();
this._subscribeMap.clear();
}
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "egg-rpc-for-apache-dubbo",
"version": "1.0.0",
"name": "egg-dubbo-rpc",
"version": "1.1.0",
"description": "dubbo rpc plugin for egg",
"eggPlugin": {
"name": "dubboRpc",
Expand All @@ -16,20 +16,20 @@
"dependencies": {
"address": "^1.1.0",
"js-remoting-for-apache-dubbo": "^1.0.0",
"nacos": "^1.1.2",
"nacos": "^2.0.0",
"sdk-base": "^3.6.0",
"sofa-rpc-node": "^1.12.0"
},
"devDependencies": {
"autod": "^3.1.0",
"autod-egg": "^1.1.0",
"egg": "^2.21.1",
"egg": "^2.22.2",
"egg-bin": "^4.13.0",
"egg-mock": "^3.22.2",
"egg-mock": "^3.22.4",
"egg-rpc-base": "^1.3.1",
"egg-rpc-generator": "^1.3.1",
"eslint": "^5.16.0",
"eslint-config-egg": "^7.3.1",
"eslint-config-egg": "^7.4.1",
"mz-modules": "^2.1.0",
"webstorm-disable-index": "^1.2.0",
"zookeeper-cluster-client": "^3.0.0"
Expand Down

0 comments on commit 1ca7188

Please sign in to comment.