cloudflare / miniflare

🔥 Fully-local simulator for Cloudflare Workers. For the latest version, see https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare.
https://miniflare.dev
MIT License
3.78k stars 205 forks source link

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

Closed mrbbot closed 1 year ago

mrbbot commented 1 year ago

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().

changeset-bot[bot] commented 1 year ago

⚠️ No Changeset found

Latest commit: 4a23fbafd0cc5e77e58b71e6a83f6f28c5467a49

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](https://github.com/cloudflare/miniflare/new/bcoll/tre-get-fetcher?filename=.changeset/silver-toes-marry.md&value=---%0A%22%40fake-scope%2Ffake-pkg%22%3A%20patch%0A---%0A%0A%5BMiniflare%203%5D%20Add%20%60getFetcher()%60%20for%20dispatching%20%60fetch%60%2F%60scheduled%60%2F%60queue%60%20events%0A)