Skip to content
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

Queues support #2064

Merged
merged 13 commits into from
Nov 4, 2022
Merged

Queues support #2064

merged 13 commits into from
Nov 4, 2022

Conversation

jbw1991
Copy link
Contributor

@jbw1991 jbw1991 commented Oct 21, 2022

This is ready for review!

Notable changes:

  • Adds new "queues" CLI subcommand for interacting with Queues (create/delete/list)
  • Adds support for Queue producer/consumer configuration in wrangler.toml
  • Updates "publish" to both:
    • Incude Queue bindings (Producers) in the script upload API call
    • Make additional API calls to configure Queue Consumers
  • Updates "dev" to support running Queues in local mode

jbw1991 and others added 5 commits September 8, 2022 09:13
* Add CLI commands for Queues

* Handle queue producers and consumers on wrangler publish

* fixup! Handle queue producers and consumers on wrangler publish

* Remove consumer commands from CLI

* Update queue settings names

Co-authored-by: Josh Wheeler <jwheeler@cloudflare.com>
* Support queues in wrangler dev local mode. remote mode is an error for now

* fixup! Support queues in wrangler dev local mode. remote mode is an error for now

* Move remote wrangler dev + queues check

Co-authored-by: Josh Wheeler <jwheeler@cloudflare.com>
@changeset-bot
Copy link

changeset-bot bot commented Oct 21, 2022

🦋 Changeset detected

Latest commit: 726d636

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2022

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/3394512414/npm-package-wrangler-2064

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/2064/npm-package-wrangler-2064

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/3394512414/npm-package-wrangler-2064 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.developers.workers.dev/runs/3394512414/npm-package-cloudflare-pages-shared-2064

@codecov
Copy link

codecov bot commented Oct 21, 2022

Codecov Report

Merging #2064 (726d636) into main (02ca556) will increase coverage by 0.26%.
The diff coverage is 91.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2064      +/-   ##
==========================================
+ Coverage   73.16%   73.43%   +0.26%     
==========================================
  Files         129      139      +10     
  Lines        8668     8965     +297     
  Branches     2270     2327      +57     
==========================================
+ Hits         6342     6583     +241     
- Misses       2326     2382      +56     
Impacted Files Coverage Δ
packages/wrangler/src/secret/index.ts 86.56% <ø> (ø)
packages/wrangler/src/worker.ts 71.42% <ø> (ø)
packages/wrangler/src/dev/local.tsx 27.05% <25.00%> (-0.09%) ⬇️
packages/wrangler/src/dev.tsx 87.73% <50.00%> (-0.36%) ⬇️
packages/wrangler/src/config/validation.ts 90.77% <87.03%> (-0.36%) ⬇️
packages/wrangler/src/publish/publish.ts 86.11% <90.32%> (+0.40%) ⬆️
packages/wrangler/src/queues/client.ts 97.29% <97.29%> (ø)
packages/wrangler/src/config/index.ts 92.59% <100.00%> (+0.28%) ⬆️
packages/wrangler/src/create-worker-upload-form.ts 93.47% <100.00%> (+0.14%) ⬆️
packages/wrangler/src/dev/start-server.ts 66.88% <100.00%> (+0.22%) ⬆️
... and 16 more

@jbw1991 jbw1991 marked this pull request as ready for review October 25, 2022 14:00
…t they are needeed for development and early testing
Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be exciting to get queues support landed! I had a couple comments, mainly around import export conventions

packages/wrangler/src/__tests__/publish.test.ts Outdated Show resolved Hide resolved
packages/wrangler/src/__tests__/publish.test.ts Outdated Show resolved Hide resolved
packages/wrangler/src/queues/cli/commands/consumer/add.ts Outdated Show resolved Hide resolved
packages/wrangler/src/queues/cli/config.ts Outdated Show resolved Hide resolved
packages/wrangler/src/queues/client.ts Outdated Show resolved Hide resolved
packages/wrangler/src/queues/cli/commands/list.ts Outdated Show resolved Hide resolved
@jbw1991 jbw1991 changed the title [WIP] Queues support Queues support Nov 1, 2022
@jbw1991
Copy link
Contributor Author

jbw1991 commented Nov 2, 2022

👋 Hey @rozenmd @penalosa I think I have covered all of your comments, please let me know if there are any other desired changes or if we should pull anyone else in.

Otherwise, I think this is ready to go 😄 . I also attempted a changeset for the first time. Let me know if it needs work.

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Anything marked as non-blocking (mainly the MSW stuff) doesn't need to be done by end of this week.

packages/wrangler/src/publish/publish.ts Outdated Show resolved Hide resolved
packages/wrangler/src/publish/publish.ts Outdated Show resolved Hide resolved
packages/wrangler/src/publish/publish.ts Outdated Show resolved Hide resolved
packages/wrangler/src/publish/publish.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have anything else that is jumping out at me, it looks great. Tentatively approving on @penalosa's follow up. (DM internally if need be @jbw1991, lets get this in today 😃 )

Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good! One lingering comment, but other than that lgtm

Comment on lines 940 to 944
const queueErr = err as FetchError;
if (queueErr.code === 100123) {
// queue_not_found
throw new Error(
`Queue "${queue}" does not exist. To create it, run: wrangler queues create ${queue}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed it in the first review, but this catch block shouldn't swallow all non-handled errors—it should re-throw them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, that was the intent. Nice catch! Fixed.

@Skye-31
Copy link
Contributor

Skye-31 commented Nov 4, 2022

Fwiw, queues need to be added the the D1 Shim file for it them to work with D1, see https://github.com/cloudflare/wrangler2/blob/main/packages/wrangler/templates/d1-beta-facade.js#L165-L173

@JacobMGEvans
Copy link
Contributor

Fwiw, queues need to be added the the D1 Shim file for it them to work with D1, see https://github.com/cloudflare/wrangler2/blob/main/packages/wrangler/templates/d1-beta-facade.js#L165-L173

I have no context on the shim, I will take @Skye-31's word on this @jbw1991

@penalosa
Copy link
Contributor

penalosa commented Nov 4, 2022

I think @geelen might have some more context on the D1 shim? Let's not merge this until that's figured out

@Skye-31
Copy link
Contributor

Skye-31 commented Nov 4, 2022

The shim calls the normal worker when D1 is used, but as it doesn't export a queue handler, the API throws the error of "no queue consumer exported" (or something similar)

https://discord.com/channels/595317990191398933/1022981666744061972/1035613298860773387 for employees who can see it, @JacobMGEvans

@jbw1991
Copy link
Contributor Author

jbw1991 commented Nov 4, 2022

@Skye-31 Thanks, I created an issue for the D1+Queues bug: #2131
We'll tackle that ASAP next week after getting @geelen 's input.

@jbw1991 jbw1991 merged commit 49b6a48 into main Nov 4, 2022
@jbw1991 jbw1991 deleted the queues branch November 4, 2022 16:13
@github-actions github-actions bot mentioned this pull request Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants