MQ-1200 Add response body to queue send() and sendBatch()#6354
Conversation
| jsg::JsValue body, | ||
| jsg::Optional<SendOptions> options, | ||
| const jsg::TypeHandler<SendResponse>& responseHandler); | ||
|
|
There was a problem hiding this comment.
I forget, did we decide to put send() / sendBatch() with responses behind a compat flag? To me this change looks non-breaking, and so does not necessarily need to be behind a compat flag. It'd certainly make implementation a lot simpler too?
There was a problem hiding this comment.
Leaving this here for posterity:
Based on discussions, we decided to put these changes under the experimental flag. After internal testing, we'll need to put in a PR to remove the experimental flag and also regenerate the production type files. We were imagining all the metrics changes can go in together, so this may be the easier approach for us.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6354 +/- ##
==========================================
- Coverage 70.79% 70.78% -0.01%
==========================================
Files 427 427
Lines 117724 117869 +145
Branches 18909 18935 +26
==========================================
+ Hits 83338 83438 +100
- Misses 23132 23160 +28
- Partials 11254 11271 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a88a242 to
e7cc945
Compare
src/workerd/api/queue.c++
Outdated
| KJ_IF_SOME(result, responseHandler.tryUnwrap(js, parsed)) { | ||
| return kj::mv(result); | ||
| } | ||
| _JSG_INTERNAL_FAIL_REQUIRE(JSG_EXCEPTION(Error), "Failed to parse queue send response", text); |
There was a problem hiding this comment.
Use JSG_REQUIRE_NONNULL instead.
There was a problem hiding this comment.
Thanks, updated!
src/workerd/api/queue.c++
Outdated
| return kj::mv(result); | ||
| } | ||
| _JSG_INTERNAL_FAIL_REQUIRE( | ||
| JSG_EXCEPTION(Error), "Failed to parse queue sendBatch response", text); |
There was a problem hiding this comment.
Use JSG_REQUIRE_NONNULL... and just in general, don't use the _-prefixed macros directly.
There was a problem hiding this comment.
Updates as well, thanks! I noticed my changes in the metrics() PR had the same issue, I will submit a follow up PR to clean that up.
e7cc945 to
648cdb6
Compare
648cdb6 to
22f1aa9
Compare
22f1aa9 to
dda70b4
Compare
|
Manual run of internal-build succeeds. Merging. |
Summary
Adds support for returning structured JSON responses from the
send()andsendBatch()methods from a worker'senv.QUEUEbinding. The changes are gated behind thequeue_send_response_body/no_queue_send_response_bodyflag.Changes
Depending on the experimental
queue_send_response_bodyflag, eitherPromise<void>orPromise<QueueSendResponse>will be returned by the send methods. In order to support both the old and new return types, the functions had to be duplicated.On the Typescript side, these new functions are exposed with the same name.
Upstream changes can be found here: https://gitlab.cfdata.org/cloudflare/mq/queue-broker-worker/-/merge_requests/1768#c210bdd061230e9c1f9da3b517fbecabd025c5c4
Testing
bazel test //src/workerd/api/tests:queue-test@bazel test //src/workerd/api/tests:queue-test@all-compat-flagsbazel test //src/workerd/api/tests:queue-producer-metadata-test@bazel test //src/workerd/api/tests:queue-producer-metadata-test@all-compat-flags