-
Notifications
You must be signed in to change notification settings - Fork 109
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
Pass request options to Database.query() etc. #817
Comments
Removes the "arangojs instrumentation" code, which was a copy of the core request processing classes of arangojs. The update to arangojs 10 would have required major changes to these files, and they were a code quality problem anyway. Instead of our custom patches, we now rely on beforeRequest and afterResponse. They can be specified once per Database, which is not sufficient for our use case, so we currently call request() directly instead of the proper executeTransaction(). Hopefully, arangojs will add a way to specify these hooks in executeTransaction() as well. See arangodb/arangojs#817 for the feature request. BREAKING CHANGE: arangojs 8 is no longer supported. Update to arangojs 10. BREAKING CHANGE: ArangoJSConfig is no longer exported. Import ConfigOptions from arangojs/configuration directly if needed.
Removes the "arangojs instrumentation" code, which was a copy of the core request processing classes of arangojs. The update to arangojs 10 would have required major changes to these files, and they were a code quality problem anyway. Instead of our custom patches, we now rely on beforeRequest and afterResponse. They can be specified once per Database, which is not sufficient for our use case, so we currently call request() directly instead of the proper executeTransaction(). Hopefully, arangojs will add a way to specify these hooks in executeTransaction() as well. See arangodb/arangojs#817 for the feature request. BREAKING CHANGE: arangojs 8 is no longer supported. Update to arangojs 10. BREAKING CHANGE: ArangoJSConfig is no longer exported. Import ConfigOptions from arangojs/configuration directly if needed.
Removes the "arangojs instrumentation" code, which was a copy of the core request processing classes of arangojs. The update to arangojs 10 would have required major changes to these files, and they were a code quality problem anyway. Instead of our custom patches, we now rely on beforeRequest and afterResponse. They can be specified once per Database, which is not sufficient for our use case, so we currently call request() directly instead of the proper executeTransaction(). Hopefully, arangojs will add a way to specify these hooks in executeTransaction() as well. See arangodb/arangojs#817 for the feature request. BREAKING CHANGE: arangojs 8 is no longer supported. Update to arangojs 10. BREAKING CHANGE: ArangoJSConfig is no longer exported. Import ConfigOptions from arangojs/configuration directly if needed.
Removes the "arangojs instrumentation" code, which was a copy of the core request processing classes of arangojs. The update to arangojs 10 would have required major changes to these files, and they were a code quality problem anyway. Instead of our custom patches, we now rely on beforeRequest and afterResponse. They can be specified once per Database, which is not sufficient for our use case, so we currently call request() directly instead of the proper executeTransaction(). Hopefully, arangojs will add a way to specify these hooks in executeTransaction() as well. See arangodb/arangojs#817 for the feature request. BREAKING CHANGE: arangojs 8 is no longer supported. Update to arangojs 10. BREAKING CHANGE: ArangoJSConfig is no longer exported. Import ConfigOptions from arangojs/configuration directly if needed.
Since the We'll likely not implement an API change like this as we already avoided this for other things that could potentially affect any request like streaming transactions. |
That would allow to correlated Going through the "My use cases" (the "other potential use cases" are not related to beforeRequest/afterResponse) Aborting an ArangoDB request when the user aborted their requestThis means I need to throw in app.get('/', (req, res) => {
let aborted = false;
res.once('close', () => { if (!res.writableFinished) { aborted = true; } }); // there should be an easier way but it's broken https://github.com/nodejs/node/issues/46666
db.query(aql`FOR obj in collection return ...`, {
beforeRequest: () => { if (aborted) { throw new Error('User aborted the request'); } }
}).then(result => res.send(...));
}); I don't think there currently is a way to implement this without the feature I proposed here. Time trackingWhile you can implement a very basic time tracking using just
All of this would be easy to implement if I could correlate the |
I would like to have a way to pass some request-related options when calling high-level methods like Database.query(), Database.executeTransaction() etc. I'm mainly interested in
beforeRequest
andafterResponse
, but I think all ofCommonRequestOptions
would make sense. In addition, the options could include asignal
to be able to abort a request.My use cases
beforeRequest
, or with a newsignal
option that I could abort.beforeRequest
callback per Database instance, but it would be possible with abeforeRequest
option on the.query()
callOther potential use cases
retryOnConflict
depending on the context, e.g. enable them for simple queries, but disable them if you want to retry on a higher level instead, or increase the number of retries for certain queriesSuggested API
The new options could be merged into all option arguments that perform a request. Personally, I'm mostly interested in
query
,executeTransaction
,beginTransaction
,Transaction.commit()
,Transaction.abort()
and the cursor APIs (although we currently don't use cursors).Alternatively, the request options could also be nested to separate them from the function-specific options
The text was updated successfully, but these errors were encountered: