Skip to content

Commit

Permalink
Review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccallum81 committed May 3, 2018
1 parent bbc5d56 commit 35929a3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ class Context {
* @memberof Service
*/
_trackContext(service) {
if ( !service.activeContexts ) {
service.activeContexts = [];
if ( !service._activeContexts ) {
service._activeContexts = [];
}
service.activeContexts.push(this);
service._activeContexts.push(this);
this.trackedBy = service;
}

Expand All @@ -93,8 +93,8 @@ class Context {
* @memberof Service
*/
dispose() {
if ( this.trackedBy && this.trackedBy.activeContexts ) {
const contextList = this.trackedBy.activeContexts;
if ( this.trackedBy && this.trackedBy._activeContexts ) {
const contextList = this.trackedBy._activeContexts;
const contextIndex = contextList.indexOf(this);
if (contextIndex !== -1) {
contextList.splice(contextIndex, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/service-broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const defaultOptions = {
heartbeatTimeout: 15,

trackContext: false,
gracefulStopTimeout: 2000,
$gracefulStopTimeout: 2000,

This comment has been minimized.

Copy link
@icebob

icebob May 3, 2018

Member

No-no, please just in service settings. In broker options leave it without $ :)


disableBalancer: false,

Expand Down
6 changes: 3 additions & 3 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Service {
const contextDisposeCatch = (ret) => {
return this.Promise.reject(contextDispose(ret));
};
return innerAction.handler(ctx).then(contextDispose, contextDisposeCatch);
return innerAction.handler(ctx).then(contextDispose).catch(contextDisposeCatch);
};

});
Expand Down Expand Up @@ -205,7 +205,7 @@ class Service {

this.stopped = () => {
return new this.Promise((resolve, reject) => {
const timeout = setTimeout(reject, this.settings.gracefulStopTimeout || this.broker.options.gracefulStopTimeout);
const timeout = setTimeout(reject, this.settings.$gracefulStopTimeout || this.broker.options.$gracefulStopTimeout);
const checkForContexts = () => {
if (this._getActiveContexts().length === 0) {
clearTimeout(timeout);
Expand Down Expand Up @@ -292,7 +292,7 @@ class Service {
* @memberof Service
*/
_getActiveContexts() {
return this.activeContexts || [];
return this._activeContexts || [];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/unit/service-broker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe("Test ServiceBroker constructor", () => {
heartbeatTimeout : 20,
heartbeatInterval: 5,
trackContext: false,
gracefulStopTimeout: 2000,
$gracefulStopTimeout: 2000,

disableBalancer: true,
registry: {
Expand Down

0 comments on commit 35929a3

Please sign in to comment.