Describe the problem
Cloudflare Queues is currently in open beta. It would be nice to be able to consume messages from the same worker that handles HTTP requests, as opposed to having to creating a separate worker. For a worker to consume from a queue a new queue function needs to be defined on the worker object.
// worker.js
export default {
async fetch(request, env, ctx) {
// Handle request...
},
async queue(batch, env) {
// Process batch...
},
};
Currently there is no easy way to add this queue function to the woker object in the generated _worker.js.
Other Cloudflare services such as Email Workers follow a similar approach.
Describe the proposed solution
I'd suggest a special src/cloudflare-worker.js file which would export functions such as queue which then during compilation get added to the _worker.js file.
// src/cloudflare-worker.js
export const queue = (batch, env) => // Process batch...
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
Describe the problem
Cloudflare Queues is currently in open beta. It would be nice to be able to consume messages from the same worker that handles HTTP requests, as opposed to having to creating a separate worker. For a worker to consume from a queue a new
queuefunction needs to be defined on the worker object.Currently there is no easy way to add this
queuefunction to the woker object in the generated_worker.js.Other Cloudflare services such as Email Workers follow a similar approach.
Describe the proposed solution
I'd suggest a special
src/cloudflare-worker.jsfile which would export functions such asqueuewhich then during compilation get added to the_worker.jsfile.Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response