-
-
Notifications
You must be signed in to change notification settings - Fork 758
Add stats of client and pool to be accessible through agent #4157
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
Changes from 1 commit
2661544
28ec198
df86d9b
4370e3d
2947cba
39c7617
651eb86
0c22ba5
8855ecb
ab942e4
f2452c4
15bc63b
5a93529
435acc8
373736e
52e7d94
7ac13ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,8 +52,7 @@ const { | |
| kOnError, | ||
| kHTTPContext, | ||
| kMaxConcurrentStreams, | ||
| kResume, | ||
| kStats | ||
| kResume | ||
| } = require('../core/symbols.js') | ||
| const connectH1 = require('./client-h1.js') | ||
| const connectH2 = require('./client-h2.js') | ||
|
|
@@ -251,8 +250,6 @@ class Client extends DispatcherBase { | |
|
|
||
| this[kResume] = (sync) => resume(this, sync) | ||
| this[kOnError] = (err) => onError(this, err) | ||
|
|
||
| this[kStats] = new ClientStats(this) | ||
| } | ||
|
|
||
| get pipelining () { | ||
|
|
@@ -265,7 +262,7 @@ class Client extends DispatcherBase { | |
| } | ||
|
|
||
| get stats () { | ||
| return this[kStats] | ||
| return new ClientStats(this) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New class every time accessed. |
||
| } | ||
|
|
||
| get [kPending] () { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,58 +9,23 @@ const { | |
| kQueued | ||
| } = require('../core/symbols') | ||
|
|
||
| const kPool = Symbol('pool') | ||
| const kClient = Symbol('client') | ||
|
|
||
| class ClientStats { | ||
| constructor (client) { | ||
| this[kClient] = client | ||
| } | ||
|
|
||
| get connected () { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not getters just instance properties. |
||
| return this[kClient][kConnected] | ||
| } | ||
|
|
||
| get pending () { | ||
| return this[kClient][kPending] | ||
| } | ||
|
|
||
| get running () { | ||
| return this[kClient][kRunning] | ||
| } | ||
|
|
||
| get size () { | ||
| return this[kClient][kSize] | ||
| this.connected = client[kConnected] | ||
| this.pending = client[kPending] | ||
| this.running = client[kRunning] | ||
| this.size = client[kSize] | ||
| } | ||
| } | ||
|
|
||
| class PoolStats { | ||
| constructor (pool) { | ||
| this[kPool] = pool | ||
| } | ||
|
|
||
| get connected () { | ||
| return this[kPool][kConnected] | ||
| } | ||
|
|
||
| get free () { | ||
| return this[kPool][kFree] | ||
| } | ||
|
|
||
| get pending () { | ||
| return this[kPool][kPending] | ||
| } | ||
|
|
||
| get queued () { | ||
| return this[kPool][kQueued] | ||
| } | ||
|
|
||
| get running () { | ||
| return this[kPool][kRunning] | ||
| } | ||
|
|
||
| get size () { | ||
| return this[kPool][kSize] | ||
| this.connected = pool[kConnected] | ||
| this.free = pool[kFree] | ||
| this.pending = pool[kPending] | ||
| this.queued = pool[kQueued] | ||
| this.running = pool[kRunning] | ||
| this.size = pool[kSize] | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand this design. Instead of using getters, I would allocate new objects. This ensures that data is stable in time without having to copy them.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be fair I also didn't but this it the current implementation and I am following it assuming it has reasoning. In that this code is just moved from elsewhere as requested by @metcoder95. Do you wish to have this changed here or as a follow up?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👋🏼 What's the implicit agreement here? Refactor as a follow-up, not at all or here? I understand the issue that the using getters can cause inconsistent as a whole with single values. I assume we would return an object of a "stats bag" in the pool and agent. Just not sure when/where to implement it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @metcoder95 what's missing on this PR to land this? Anything expected from my side?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just applying the suggested refactor from getters to a plain object (it can also come from a class, but avoiding the getters/setters).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. From what I understand 7ac13ff is what you had in mind? |
||
|
|
||
|
|
||
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.
Not needed anymore. Not assigned as property any longer.