-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rethinkdb reconnection #21
base: master
Are you sure you want to change the base?
Conversation
this._splitChar = options.splitChar || null | ||
this._tableMatch = this._splitChar ? | ||
new RegExp('^(\\w+)' + this._escapeRegExp(this._splitChar)) : | ||
null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
Too many errors. (21% scanned).
this._defaultTable = options.defaultTable || 'deepstream_records' | ||
this._splitChar = options.splitChar || null | ||
this._tableMatch = this._splitChar ? | ||
new RegExp('^(\\w+)' + this._escapeRegExp(this._splitChar)) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
this._reconnectCount = this._connection.reconnectCount | ||
this._tableManager = new TableManager(this._connection) | ||
this._defaultTable = options.defaultTable || 'deepstream_records' | ||
this._splitChar = options.splitChar || null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
this._connection = new Connection(options, this._onConnection.bind(this)) | ||
this._reconnectCount = this._connection.reconnectCount | ||
this._tableManager = new TableManager(this._connection) | ||
this._defaultTable = options.defaultTable || 'deepstream_records' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
Missing semicolon.
this._options = options | ||
this._connection = new Connection(options, this._onConnection.bind(this)) | ||
this._reconnectCount = this._connection.reconnectCount | ||
this._tableManager = new TableManager(this._connection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
*/ | ||
constructor(options) { | ||
super() | ||
this.isReady = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
* @constructor | ||
*/ | ||
constructor(options) { | ||
super() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
* | ||
* database specifies which database to use. Defaults to 'deepstream' | ||
* defaultTable specifies which table records will be stored in that don't specify a table. Defaults to deepstream_records | ||
* splitChar specifies a character that separates the record's id from the table it should be stored in. defaults to null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
* Please note the three additional, optional keys: | ||
* | ||
* database specifies which database to use. Defaults to 'deepstream' | ||
* defaultTable specifies which table records will be stored in that don't specify a table. Defaults to deepstream_records |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
* for instance will create a user table and store it in it. This will allow for more sophisticated queries as | ||
* well as speed up read operations since there are less entries to look through | ||
* | ||
* @param {Object} options rethinkdb driver options. See rethinkdb.com/api/javascript/#connect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
@@ -29,7 +29,7 @@ describe( 'it distributes records between multiple tables', () => { | |||
}) | |||
|
|||
it( 'deletes dsTestA', ( done ) => { | |||
conn = cacheConnector._connection.get() | |||
conn = cacheConnector._connection.connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
@@ -53,7 +53,7 @@ describe( 'Is able to insert a larger number of values in quick succession', () | |||
}) | |||
|
|||
it( 'deletes dsTestA', ( done ) => { | |||
const conn = storageConnector._connection.get() | |||
const conn = storageConnector._connection.connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Missing semicolon.
setTimeout(() => cacheConnector.get('someValue', (error, value) => { | ||
expect(error).to.equal(null) | ||
expect(value).to.deep.equal(data) | ||
done() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
Too many errors. (27% scanned).
expect(error.msg).to.equal("Connection is closed.") | ||
setTimeout(() => cacheConnector.get('someValue', (error, value) => { | ||
expect(error).to.equal(null) | ||
expect(value).to.deep.equal(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
}).then(cacheConnector.get('someValue', (error) => { | ||
expect(error.msg).to.equal("Connection is closed.") | ||
setTimeout(() => cacheConnector.get('someValue', (error, value) => { | ||
expect(error).to.equal(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
setTimeout(() => cacheConnector.set('someValue', data, (error) => { | ||
expect(error).to.equal(null) | ||
done() | ||
}), 1500) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
expect(error.msg).to.equal("Connection is closed.") | ||
setTimeout(() => cacheConnector.set('someValue', data, (error) => { | ||
expect(error).to.equal(null) | ||
done() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
}).then(cacheConnector.set('someValue', data, (error) => { | ||
expect(error.msg).to.equal("Connection is closed.") | ||
setTimeout(() => cacheConnector.set('someValue', data, (error) => { | ||
expect(error).to.equal(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
noreplyWait: true | ||
}).then(cacheConnector.set('someValue', data, (error) => { | ||
expect(error.msg).to.equal("Connection is closed.") | ||
setTimeout(() => cacheConnector.set('someValue', data, (error) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
cacheConnector._connection._connection.close({ | ||
noreplyWait: true | ||
}).then(cacheConnector.set('someValue', data, (error) => { | ||
expect(error.msg).to.equal("Connection is closed.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed double and single quotes.
Missing semicolon.
10d57d3
to
e6ad910
Compare
For an uws issue, the rethinkdb instance in our cluster assigned to a deepstream instance sometimes crases. In such case, the deepstream instance cannot recover: it logs the lost connection then game over.
In this PR I have added some configurable reconnection logic (see the readme). If you don't specify the new config parameters, then deepstream should behave as before, however, when you do it, and the plugin is able to recognize the lost rethinkdb connection, then it will try to reconnect, then re-execute the failed operation.
Which means that the deepstream instance gets another, working rethinkdb instance from the cluster and completes the operation. Otherwise, it stays in the failed status as before.