-
Notifications
You must be signed in to change notification settings - Fork 232
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
Fix queue details not loading - because of switch from node-redis to ioredis #459
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,12 +31,35 @@ function formatBytes(num) { | |
return (neg ? '-' : '') + numStr + ' ' + unit; | ||
} | ||
|
||
function splitInfo(res) { | ||
if (typeof res !== 'string') { | ||
return {}; | ||
} | ||
|
||
const serverInfo = {}; | ||
const lines = res.split('\r\n'); | ||
for (let i = 0; i < lines.length; ++i) { | ||
if (lines[i]) { | ||
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. Could eliminate an indent-level by dropping this. Empty lines are insignificant already with the Feels like a premature optimisation (esp. given that the frequency of empty lines in |
||
const line = lines[i].trim(); | ||
if (!line.startsWith('#')) { | ||
const idx = line.indexOf(':'); | ||
if (idx > 0) { | ||
serverInfo[line.substring(0, idx)] = line.substring(idx + 1); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return serverInfo; | ||
} | ||
|
||
const Helpers = { | ||
getStats: async function (queue) { | ||
const client = await queue.client; | ||
await client.info(); // update queue.client.serverInfo | ||
const info = await client.info(); // In node-redis this will update queue.client.serverInfo | ||
|
||
const stats = _.pickBy(client.serverInfo, (value, key) => | ||
// In ioredis we need to parse this information: | ||
const stats = _.pickBy(client.serverInfo || splitInfo(info), (value, key) => | ||
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'd expect For example, given Of course, given It'd be better to parse each time so we've fresh data regardless the configuration of 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. As of Bull v4.0.0 we do in fact have |
||
_.includes(this._usefulMetrics, key) | ||
); | ||
stats.used_memory = formatBytes(parseInt(stats.used_memory, 10)); | ||
|
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.
(pedantic)
splitInfo
is overly vague – consider instead something likeparseRedisServerInfo
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.
Similarly,
res
is a bit arbitrary and might imply a web response, etc. but I digress.