-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add _queue-status endpoint to realm server #2070
Conversation
Host Test Results 1 files ± 0 1 suites ±0 22m 50s ⏱️ +55s Results for commit a36644b. ± Comparison against base commit 316d35f. This pull request removes 1 and adds 51 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
return async function (ctxt: Koa.Context, _next: Koa.Next) { | ||
let [{ pending_job_count }] = (await query(dbAdapter, [ | ||
`SELECT COUNT(*) as pending_job_count FROM jobs WHERE status='unfulfilled'`, | ||
])) as { | ||
pending_job_count: string; | ||
}[]; | ||
return setContextResponse( | ||
ctxt, | ||
new Response( | ||
JSON.stringify({ | ||
data: { | ||
type: 'queue-status', | ||
id: 'queue-status', | ||
attributes: { | ||
pending: parseInt(pending_job_count, 10), | ||
}, | ||
}, | ||
}), | ||
{ | ||
headers: { 'content-type': SupportedMimeType.JSONAPI }, | ||
}, | ||
), | ||
); | ||
}; | ||
} |
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.
is it ok that this is an unprotected route? perhaps we should have a shared secret to access this? otherwise a malicious client might try to DDoS our DB impacting the system overall.
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.
In our previous projects we had a x-data-integrity-checks-authorization
header was used to authorize requests of this type. Perhaps we could have something similar here, depending on the service that will consume this
c686323
to
a36644b
Compare
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!
No description provided.