Skip to content
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

refactor: migrate cluster-related code to TypeScript #717

Merged
merged 4 commits into from
Oct 14, 2018
Merged

Conversation

luin
Copy link
Collaborator

@luin luin commented Oct 9, 2018

No description provided.

Copy link

@SimonSchick SimonSchick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comments.

You might want to consider cleaning up JSDoc in general as you touch code btw.

/**
* Creates a Redis Cluster instance
*
* @constructor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably omit most of those @constructor and other class related hints.

import ConnectionPool from './ConnectionPool'
import {NodeKey, IRedisOptions, normalizeNodeOptions} from './util'

var Deque = require('denque')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of those requires can probably be moved to import (namely node and some of your own).
Everything should probably be const

*
* @private
*/
_handleCloseEvent () {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get rid of @public and @private and use the keywords instead.

}
return asCallback(
Promise.all(this.nodes().map(function (node) {
return node.quit()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sometimes would throw if node that we issue quit to is already in the disconnected state (often in the tests where redis instance is down before the quit is processed)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I'll fix this in a separate commit.

private setStatus(status: ClusterStatus): void {
debug('status: %s -> %s', this.status || '[empty]', status)
this.status = status
process.nextTick(this.emit.bind(this, status))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.emit.bind could be saved as a reference, ie boundEmit
and then we can process.nextTick(this.boundEmit, status) - that should be a bit faster

@luin luin merged commit 16643e2 into master Oct 14, 2018
@luin luin deleted the cluster/typescript branch October 14, 2018 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants