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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Miniflare 3] Add getFetcher() for dispatching fetch/scheduled/queue events #708

Merged
merged 2 commits into from
Oct 10, 2023

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Oct 5, 2023

Hey! 馃憢 This change adds back support for dispatching scheduled and queue events directly. Miniflare 2 previously provided similar dispatchScheduled() and dispatchQueue() methods, but these implemented an inconsistent, non-standard API.

With getFetcher(), we're able to reuse magic proxy code to support arbitrary Workers APIs. This is important for queue(), which supports sending any structured serialisable as a message body.

getFetcher() also provides an idiomatic Miniflare API for dealing with multiple workers, matching that provided by getBindings().

This change adds back support for dispatching `scheduled` and `queue`
events directly. Miniflare 2 previously provided similar
`dispatchScheduled()` and `dispatchQueue()` methods, but these
implemented an inconsistent, non-standard API.

With `getFetcher()`, we're able to reuse magic proxy code to support
arbitrary Workers APIs. This is important for `queue()`, which
supports sending any structured serialisable as a message `body`.

`getFetcher()` also provides an idiomatic Miniflare API for dealing
with multiple workers, matching that provided by `getBindings()`.
@mrbbot mrbbot requested a review from a team October 5, 2023 20:57
@changeset-bot
Copy link

changeset-bot bot commented Oct 5, 2023

鈿狅笍 No Changeset found

Latest commit: 4a23fba

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

compatibility flag to expose
[`scheduled()`](https://workers-types.pages.dev/experimental/#Fetcher.scheduled)
and [`queue()`](https://workers-types.pages.dev/experimental/#Fetcher.queue)
methods for dispatching `scheduled` and `queue` events.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might be nice to add an example here, with a <details>.

@mrbbot mrbbot merged commit ff17f0c into tre Oct 10, 2023
8 checks passed
@mrbbot mrbbot deleted the bcoll/tre-get-fetcher branch October 10, 2023 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants