Skip to content

Commit

Permalink
feat: add service publish info (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
gxcsoccer authored Oct 22, 2018
1 parent 38164c4 commit e3af79a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/client/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class RpcConsumer extends Base {
}

parseUrl(url) {
assert(typeof url === 'string', 'parseUrl(url) url should be string');
const address = urlparse(url.indexOf('://') >= 0 ? url : `bolt://${url}`, true);
if (!address.port) {
address.port = 12200;
Expand Down
2 changes: 2 additions & 0 deletions lib/server/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class RpcService extends Base {
normalizeReg(url) {
return {
interfaceName: this.interfaceName,
version: this.version,
group: this.group,
url,
};
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"coffee": "^5.1.0",
"contributors": "^0.5.1",
"egg-bin": "^4.9.0",
"eslint": "^5.6.1",
"eslint": "^5.7.0",
"eslint-config-egg": "^7.1.0",
"mm": "^2.4.1",
"pedding": "^1.1.0"
Expand Down
7 changes: 7 additions & 0 deletions test/server/service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ describe('test/server/service.test.js', () => {
assert(!service.app);
assert(!service.registry);

assert.deepEqual(service.normalizeReg('bolt://127.0.0.1:12200'), {
interfaceName: 'com.node.test.TestService',
version: '1.0',
group: 'SOFA',
url: 'bolt://127.0.0.1:12200',
});

await service.publish('bolt://127.0.0.1:12200');
assert(!service.publishUrl);
await service.unPublish();
Expand Down

0 comments on commit e3af79a

Please sign in to comment.