-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: app.cluster auto bind this #570
Conversation
39cdbdc
to
b9f8c5b
Compare
// agent worker is leader, app workers are follower | ||
options.isLeader = this.type === 'agent'; | ||
options.logger = this.coreLogger; | ||
const client = cluster(clientClass, options); |
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.
不是这样的吧
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.
等下 加个用例
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.
放这里有用么? 下面的 this 还是取不到吧,感觉需要将方法定义在下面,然后 this.cluster = this.cluster.bind(this)
?
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
Codecov Report
@@ Coverage Diff @@
## master #570 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 26 26
Lines 632 633 +1
=====================================
+ Hits 632 633 +1
Continue to review full report at Codecov.
|
02557ec
to
a26eeb1
Compare
@@ -6,7 +6,8 @@ module.exports = function(app) { | |||
const done = app.readyCallback('register_client', { | |||
isWeakDep: app.config.runMode === 0, | |||
}); | |||
app.registryClient = app.cluster(RegistryClient).create(); | |||
const cluster = app.cluster; | |||
app.registryClient = cluster(RegistryClient).create(); |
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.
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.
options.cluster = app.cluster;
app.registryClient = new RegistryClient(options);
这样才对的
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.
哦,这里的 RegistryClient 是 DataClient
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.
LGTM
Checklist
npm test
passesAffected core subsystem(s)
plugin development
Description of change