Skip to content

Commit

Permalink
Update for Gaggle version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Ng committed Oct 29, 2016
1 parent c44ce4a commit a7a9053
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions lib/conflux.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ Conflux = function Conflux (opts) {
, gOpts = _.assign(_.omit(opts, 'reduce', 'methods'), {
accelerateHeartbeats: true
, rpc: {
performMethod: function (methodName, args, cb) {
performMethod: function (methodName, args) {
var result

if (typeof self._methods[methodName] !== 'function') {
cb(new Error(methodName + ' is not a registered method'))
return new Error(methodName + ' is not a registered method')
}
else if (self._nudgeCluster()) {
cb(new Error('the cluster is not ready yet, try again in a few seconds'))
return new Error('the cluster is not ready yet, try again in a few seconds')
}
else {
result = self._methods[methodName].apply(self, args)

if (result instanceof Error) {
cb(result)
return result
}
else {
if (result != null) {
self._dispatch(result)
cb(null, result)
self._appendAction(result)
return result
}
else {
cb(null)
return null
}
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ Conflux.prototype.subscribe = function subscribe (cb) {
}
}

Conflux.prototype._dispatch = function _dispatch (action) {
Conflux.prototype._appendAction = function _appendAction (action) {
return this._gaggle.append({
type: ACTION_TYPE
, data: action
Expand All @@ -106,10 +106,10 @@ Conflux.prototype.perform = function perform (methodName, args, timeout, cb) {
return this._gaggle.dispatchOnLeader('performMethod', [methodName, args], timeout)
.then(function (ret) {
if (typeof cb === 'function') {
cb(null, ret[0])
cb(null, ret)
}
else {
return Promise.resolve(ret[0])
return Promise.resolve(ret)
}
})
.catch(function (err) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"bluebird": "^3.1.1",
"gaggle": "^2.1.3",
"gaggle": "ben-ng/gaggle#p2p",
"in-publish": "^2.0.0",
"joi": "^6.10.0",
"lodash": "^4.0.0",
Expand Down

0 comments on commit a7a9053

Please sign in to comment.