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

Add encodeBody and cf to ResponseInit. Adopt builder pattern. #568

Merged
merged 5 commits into from
May 19, 2024

Conversation

kflansburg
Copy link
Contributor

This expands ResponseInit to support all of the options available in JavaScript. Additionally, the builder pattern is adopted so that users do not have to specify all of these new fields as we add them (breaking change). There are a few questions I want to answer before merging this.

Closes #567

worker/src/response.rs Show resolved Hide resolved
worker/src/response.rs Outdated Show resolved Hide resolved
@kflansburg kflansburg requested a review from zebp May 4, 2024 12:47
@kflansburg kflansburg force-pushed the kflansburg/response-init branch from ed96771 to 1405289 Compare May 4, 2024 12:50
@kflansburg kflansburg force-pushed the kflansburg/response-init branch from 1405289 to 5766930 Compare May 4, 2024 12:58
worker/src/response.rs Outdated Show resolved Hide resolved
worker/src/response.rs Outdated Show resolved Hide resolved
@kflansburg kflansburg force-pushed the kflansburg/response-init branch from d180768 to cbd0775 Compare May 5, 2024 12:04
@kflansburg kflansburg force-pushed the kflansburg/response-init branch from cbd0775 to 451fc7f Compare May 5, 2024 12:31
@@ -2,7 +2,7 @@ use super::SomeSharedData;
use futures_util::stream::StreamExt;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes to the other files aren't necessary (there are no breaking changes to Response), but are done to adopt the new builder pattern.

worker-sys/src/ext/response_init.rs Outdated Show resolved Hide resolved
worker/src/response.rs Outdated Show resolved Hide resolved
worker/src/response.rs Outdated Show resolved Hide resolved
@kflansburg kflansburg force-pushed the kflansburg/response-init branch from 2a5e771 to d24cc39 Compare May 15, 2024 18:46
@kflansburg kflansburg requested a review from himikof May 16, 2024 11:19
@kflansburg kflansburg merged commit bfe6d56 into main May 19, 2024
3 checks passed
@kflansburg kflansburg deleted the kflansburg/response-init branch May 19, 2024 12:34
renovate bot referenced this pull request in spiraldb/vortex Jun 13, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [worker](https://togithub.com/cloudflare/workers-rs) |
workspace.dependencies | minor | `0.2.0` -> `0.3.0` |

---

### Release Notes

<details>
<summary>cloudflare/workers-rs (worker)</summary>

###
[`v0.3.0`](https://togithub.com/cloudflare/workers-rs/releases/tag/v0.3.0)

[Compare
Source](https://togithub.com/cloudflare/workers-rs/compare/v0.2.0...v0.3.0)

#### What's Changed

- Rust-friendly
[DigestStream](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#constructors)
API (see
[example](https://togithub.com/cloudflare/workers-rs/blob/main/examples/digest/src/lib.rs))
by [@&#8203;dakom](https://togithub.com/dakom) in
[https://github.com/cloudflare/workers-rs/pull/529](https://togithub.com/cloudflare/workers-rs/pull/529)
- Introduce cargo generate templates and update getting started by
[@&#8203;kflansburg](https://togithub.com/kflansburg) in
[https://github.com/cloudflare/workers-rs/pull/559](https://togithub.com/cloudflare/workers-rs/pull/559)

> \[!TIP]
> You can now get started in seconds by running `cargo generate
cloudflare/workers-rs`!

- Implement Send, Sync and Clone for some Durable Object types for
better `axum` ergonomics by
[@&#8203;avsaase](https://togithub.com/avsaase) in
[https://github.com/cloudflare/workers-rs/pull/563](https://togithub.com/cloudflare/workers-rs/pull/563)
- Hyperdrive binding by [@&#8203;avsaase](https://togithub.com/avsaase)
in
[https://github.com/cloudflare/workers-rs/pull/566](https://togithub.com/cloudflare/workers-rs/pull/566)

> \[!TIP]
> You can now use [Workers
Hyperdrive](https://developers.cloudflare.com/hyperdrive/get-started/)
to speed up connections to your SQL database using `tokio-postgres`.
Check out our updated
[example](https://togithub.com/cloudflare/workers-rs/blob/main/examples/tokio-postgres/src/lib.rs).

- Add MSRV to `worker` crate by
[@&#8203;KianNH](https://togithub.com/KianNH) in
[https://github.com/cloudflare/workers-rs/pull/570](https://togithub.com/cloudflare/workers-rs/pull/570)

> \[!CAUTION]
> Rust 1.75 or greater is now required due to use of `impl Trait` in
trait method return type.

- Use `u64` for R2 range requests by
[@&#8203;kflansburg](https://togithub.com/kflansburg) in
[https://github.com/cloudflare/workers-rs/pull/564](https://togithub.com/cloudflare/workers-rs/pull/564)

> \[!CAUTION]
> In order to support range requests larger than 4GB,
`worker_sys::R2Range` now accepts `f64` instead of `u32`.
`worker::Range` options have changed to make the functionality more
clear and now accept `u64` instead of `u32`.

- Add `encodeBody` and `cf` to ResponseInit. Adopt builder pattern. by
[@&#8203;kflansburg](https://togithub.com/kflansburg) in
[https://github.com/cloudflare/workers-rs/pull/568](https://togithub.com/cloudflare/workers-rs/pull/568)

> \[!CAUTION]
> This change removes `ResponseInit`, which is replaced by an idiomatic
`ResponseBuilder` pattern, all other APIs should remain unchanged. In
addition, the `encodeBody` property is now available to support
returning pre-compressed data.

#### New Contributors

- [@&#8203;sachaos](https://togithub.com/sachaos) made their first
contribution in
[https://github.com/cloudflare/workers-rs/pull/572](https://togithub.com/cloudflare/workers-rs/pull/572)
- [@&#8203;thiskevinwang](https://togithub.com/thiskevinwang) made their
first contribution in
[https://github.com/cloudflare/workers-rs/pull/575](https://togithub.com/cloudflare/workers-rs/pull/575)

**Full Changelog**:
cloudflare/workers-rs@v0.2.0...v0.3.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/spiraldb/vortex).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjM5My4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
AdamGS referenced this pull request in AdamGS/vortex Jun 14, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [worker](https://togithub.com/cloudflare/workers-rs) |
workspace.dependencies | minor | `0.2.0` -> `0.3.0` |

---

### Release Notes

<details>
<summary>cloudflare/workers-rs (worker)</summary>

###
[`v0.3.0`](https://togithub.com/cloudflare/workers-rs/releases/tag/v0.3.0)

[Compare
Source](https://togithub.com/cloudflare/workers-rs/compare/v0.2.0...v0.3.0)

#### What's Changed

- Rust-friendly
[DigestStream](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#constructors)
API (see
[example](https://togithub.com/cloudflare/workers-rs/blob/main/examples/digest/src/lib.rs))
by [@&#8203;dakom](https://togithub.com/dakom) in
[https://github.com/cloudflare/workers-rs/pull/529](https://togithub.com/cloudflare/workers-rs/pull/529)
- Introduce cargo generate templates and update getting started by
[@&#8203;kflansburg](https://togithub.com/kflansburg) in
[https://github.com/cloudflare/workers-rs/pull/559](https://togithub.com/cloudflare/workers-rs/pull/559)

> \[!TIP]
> You can now get started in seconds by running `cargo generate
cloudflare/workers-rs`!

- Implement Send, Sync and Clone for some Durable Object types for
better `axum` ergonomics by
[@&#8203;avsaase](https://togithub.com/avsaase) in
[https://github.com/cloudflare/workers-rs/pull/563](https://togithub.com/cloudflare/workers-rs/pull/563)
- Hyperdrive binding by [@&#8203;avsaase](https://togithub.com/avsaase)
in
[https://github.com/cloudflare/workers-rs/pull/566](https://togithub.com/cloudflare/workers-rs/pull/566)

> \[!TIP]
> You can now use [Workers
Hyperdrive](https://developers.cloudflare.com/hyperdrive/get-started/)
to speed up connections to your SQL database using `tokio-postgres`.
Check out our updated
[example](https://togithub.com/cloudflare/workers-rs/blob/main/examples/tokio-postgres/src/lib.rs).

- Add MSRV to `worker` crate by
[@&#8203;KianNH](https://togithub.com/KianNH) in
[https://github.com/cloudflare/workers-rs/pull/570](https://togithub.com/cloudflare/workers-rs/pull/570)

> \[!CAUTION]
> Rust 1.75 or greater is now required due to use of `impl Trait` in
trait method return type.

- Use `u64` for R2 range requests by
[@&#8203;kflansburg](https://togithub.com/kflansburg) in
[https://github.com/cloudflare/workers-rs/pull/564](https://togithub.com/cloudflare/workers-rs/pull/564)

> \[!CAUTION]
> In order to support range requests larger than 4GB,
`worker_sys::R2Range` now accepts `f64` instead of `u32`.
`worker::Range` options have changed to make the functionality more
clear and now accept `u64` instead of `u32`.

- Add `encodeBody` and `cf` to ResponseInit. Adopt builder pattern. by
[@&#8203;kflansburg](https://togithub.com/kflansburg) in
[https://github.com/cloudflare/workers-rs/pull/568](https://togithub.com/cloudflare/workers-rs/pull/568)

> \[!CAUTION]
> This change removes `ResponseInit`, which is replaced by an idiomatic
`ResponseBuilder` pattern, all other APIs should remain unchanged. In
addition, the `encodeBody` property is now available to support
returning pre-compressed data.

#### New Contributors

- [@&#8203;sachaos](https://togithub.com/sachaos) made their first
contribution in
[https://github.com/cloudflare/workers-rs/pull/572](https://togithub.com/cloudflare/workers-rs/pull/572)
- [@&#8203;thiskevinwang](https://togithub.com/thiskevinwang) made their
first contribution in
[https://github.com/cloudflare/workers-rs/pull/575](https://togithub.com/cloudflare/workers-rs/pull/575)

**Full Changelog**:
cloudflare/workers-rs@v0.2.0...v0.3.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/spiraldb/vortex).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjM5My4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants