-
-
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2661544
Add shared stats symbol
tdeekens 28ec198
Add client stats class
tdeekens df86d9b
Use client stats in client
tdeekens 4370e3d
Adjust pool and expose stats from agent
tdeekens 2947cba
Add types for changes
tdeekens 39c7617
Add test for client
tdeekens 651eb86
Fix formatting changes
tdeekens 0c22ba5
Add types for agent stats getter
tdeekens 8855ecb
fixup! Fix formatting changes
tdeekens ab942e4
Move pool and client stats into util/stats
tdeekens f2452c4
Add tests and fix implementation
tdeekens 15bc63b
Adds documentation and fixes
tdeekens 5a93529
Fix to remove mise
tdeekens 435acc8
Restore docs list star
tdeekens 373736e
Fix boolean type
tdeekens 52e7d94
Refactor to return object over list of list
tdeekens 7ac13ff
Refactor to not use getters but object
tdeekens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Move pool and client stats into util/stats
- Loading branch information
commit ab942e49f42858f639ac6ab064deb05b1ac993da
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| 'use strict' | ||
|
|
||
| const { | ||
| kConnected, | ||
| kPending, | ||
| kRunning, | ||
| kSize, | ||
| kFree, | ||
| kQueued | ||
| } = require('../core/symbols') | ||
|
|
||
| const kPool = Symbol('pool') | ||
| const kClient = Symbol('client') | ||
|
|
||
| class ClientStats { | ||
| constructor (client) { | ||
| this[kClient] = client | ||
| } | ||
|
|
||
| get connected () { | ||
| return this[kClient][kConnected] | ||
| } | ||
|
|
||
| get pending () { | ||
| return this[kClient][kPending] | ||
| } | ||
|
|
||
| get running () { | ||
| return this[kClient][kRunning] | ||
| } | ||
|
|
||
| get size () { | ||
| return this[kClient][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] | ||
| } | ||
| } | ||
|
|
||
| module.exports = { ClientStats, PoolStats } | ||
|
tdeekens marked this conversation as resolved.
Outdated
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [tools] | ||
| node = "22" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
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?
Uh oh!
There was an error while loading. Please reload this page.
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.
👋🏼 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.
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.
@metcoder95 what's missing on this PR to land this? Anything expected from my side?
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.
Just applying the suggested refactor from getters to a plain object (it can also come from a class, but avoiding the getters/setters).
Uh oh!
There was an error while loading. Please reload this page.
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.
Sure. From what I understand 7ac13ff is what you had in mind?