Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Upgrade to Tokio 1.0 #664

Merged
merged 3 commits into from
Jan 2, 2021
Merged

Upgrade to Tokio 1.0 #664

merged 3 commits into from
Jan 2, 2021

Conversation

zeylahellyer
Copy link
Member

Upgrade Tokio to 1.0 as well as all related dependencies. In total, this results in upgrading:

  • async-tungstenite: 0.11
  • hyper: 0.14
  • hyper-rustls: 0.22
  • hyper-tls: 0.5
  • tokio: 1.0

The migration is not very interesting; changing tokio::time::delay_fors to tokio::time:sleeps and such. Tokio has changed the rt-core feature to rt and rt-threaded to rt-multi-thread, so the examples have been updated for this.

Notably, due to tokio::time::throttle being moved to a separate crate - tokio-stream - and working oddly, a thin throttle stream has been manually implemented.

Blocks on #657.

Closes #649.

@zeylahellyer zeylahellyer added c-http Affects the http crate c-gateway Affects the gateway crate m-breaking change Breaks the public API. c-lavalink Affects the lavalink crate enhancement c-gateway-queue Affects the gateway queue crate labels Dec 31, 2020
@zeylahellyer zeylahellyer marked this pull request as draft December 31, 2020 04:39
@zeylahellyer
Copy link
Member Author

zeylahellyer commented Dec 31, 2020

Rebased and ready for review

@zeylahellyer zeylahellyer marked this pull request as ready for review December 31, 2020 14:47
@zeylahellyer
Copy link
Member Author

CI fails due to spurious old clippy lints that just showed up out of the blue. #665 filed to fix this

zeylahellyer added a commit that referenced this pull request Dec 31, 2020
[PR #664]'s CI failed due to [Clippy erroring] on some lints that are
new with Rust 1.49.

[Clippy erroring]: https://github.com/twilight-rs/twilight/runs/1630617881
[PR #664]: #664

Approved-by: BlackHoleFox <blackholefoxdev@gmail.com>
Approved-by: Cassandra McCarthy <cassie@7596ff.com>
Merged-by: Vivian Hellyer <vivian@hellyer.dev>
Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
zeylahellyer added a commit that referenced this pull request Dec 31, 2020
[PR #664]'s CI failed due to [Clippy erroring] on some lints that are
new with Rust 1.49.

[Clippy erroring]: https://github.com/twilight-rs/twilight/runs/1630617881
[PR #664]: #664

Approved-by: BlackHoleFox <blackholefoxdev@gmail.com>
Approved-by: Cassandra McCarthy <cassie@7596ff.com>
Merged-by: Vivian Hellyer <vivian@hellyer.dev>
Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
@zeylahellyer zeylahellyer linked an issue Jan 1, 2021 that may be closed by this pull request
6 tasks
@zeylahellyer zeylahellyer added this to the 0.3 milestone Jan 1, 2021
Upgrade Tokio to 1.0 as well as all related dependencies. In total, this
results in upgrading:

- async-tungstenite: 0.11
- hyper: 0.14
- hyper-rustls: 0.22
- hyper-tls: 0.5
- tokio: 1.0

The migration is not very interesting; changing
`tokio::time::delay_for`s to `tokio::time:sleep`s and such. Tokio has
changed the `rt-core` feature to `rt` and `rt-threaded` to
`rt-multi-thread`, so the examples have been updated for this.

Notably, due to `tokio::time::throttle` being moved to a separate crate
- `tokio-stream` - and working oddly, a thin throttle stream has been
manually implemented.

Blocks on #657.

Closes #649.

Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
@zeylahellyer
Copy link
Member Author

Hyper PR (#657) is merged now. PR rebased, squashed, tests pass, and ready to be reviewed.

Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
@zeylahellyer zeylahellyer mentioned this pull request Jan 1, 2021
6 tasks
Copy link
Member

@Erk- Erk- left a comment

Choose a reason for hiding this comment

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

Looks overall good a few small dependency tidbits

Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
@zeylahellyer
Copy link
Member Author

Comments addressed

@zeylahellyer zeylahellyer requested a review from Erk- January 2, 2021 00:50
Copy link
Member

@Erk- Erk- left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Gelbpunkt Gelbpunkt left a comment

Choose a reason for hiding this comment

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

Changes look good, excited for 0.3 🎉

@zeylahellyer zeylahellyer merged commit 2206e68 into twilight-rs:v0.3 Jan 2, 2021
@zeylahellyer zeylahellyer deleted the tokio-1.0 branch January 2, 2021 03:20
zeylahellyer added a commit that referenced this pull request Jan 5, 2021
Upgrade Tokio to 1.0 as well as all related dependencies. In total, this
results in upgrading:

- async-tungstenite: 0.11
- hyper: 0.14
- hyper-rustls: 0.22
- hyper-tls: 0.5
- tokio: 1.0

The migration is not very interesting; changing
`tokio::time::delay_for`s to `tokio::time:sleep`s and such. Tokio has
changed the `rt-core` feature to `rt` and `rt-threaded` to
`rt-multi-thread`, so the examples have been updated for this.

Notably, due to `tokio::time::throttle` being moved to a separate crate
- `tokio-stream` - and working oddly, a thin throttle stream has been
manually implemented.

Closes #649.

Approved-by: Jens Reidel <adrian@travitia.xyz>
Approved-by: Valdemar Erk <valdemar@erk.io>
Merged-by: Vivian Hellyer <vivian@hellyer.dev>
Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
zeylahellyer added a commit that referenced this pull request Jan 8, 2021
Upgrade Tokio to 1.0 as well as all related dependencies. In total, this
results in upgrading:

- async-tungstenite: 0.11
- hyper: 0.14
- hyper-rustls: 0.22
- hyper-tls: 0.5
- tokio: 1.0

The migration is not very interesting; changing
`tokio::time::delay_for`s to `tokio::time:sleep`s and such. Tokio has
changed the `rt-core` feature to `rt` and `rt-threaded` to
`rt-multi-thread`, so the examples have been updated for this.

Notably, due to `tokio::time::throttle` being moved to a separate crate
- `tokio-stream` - and working oddly, a thin throttle stream has been
manually implemented.

Closes #649.

Approved-by: Jens Reidel <adrian@travitia.xyz>
Approved-by: Valdemar Erk <valdemar@erk.io>
Merged-by: Vivian Hellyer <vivian@hellyer.dev>
Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
zeylahellyer added a commit that referenced this pull request Jan 8, 2021
Version 0.3 has been released with the primary intent to upgrade to
Tokio 1.0.

Changes

Upgrade `tokio` from v0.2 to v1 ([#664] - [@vivian]).

[#664]: #664

Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
zeylahellyer added a commit that referenced this pull request Jan 8, 2021
Version 0.3 has been released with the primary intent to switch from
`reqwest` to the lighter `hyper` as the HTTP client and upgrade to Tokio
1.0.

Upgrade Path

`client::Client`'s `delete_webhook_from_url`,
`execute_webhook_from_url`, `update_webhook_from_url`, and
`update_webhook_with_token_from_url` methods have been removed. Instead,
use the `twilight-util` crate's new `link::webhook::parse` functionality
to parse webhook IDs and tokens out of URLs. Then, pass the webhook ID
and token to the method variants without `_from_url`; for example,
`client::Client::execute_webhook`.

`client::Client::add_role` has been removed because it was a duplicate
method. Instead use `client::Client::add_guild_member_role`.

When attaching files to a message, pass in the bytes of the attachment
instead of `reqwest`'s `Body` type.

If supplying an HTTP client to `twilight-http`, pass a `hyper` client
instead of a `reqwest` client and use
`client::ClientBuilder::hyper_client` instead of `reqwest_client`.

Instead of using `client::ClientBuilder::proxy` to pass a `reqwest`
proxy, use it to pass a string of the URL of the proxy. This is now
specifically noted to be used with applications like Twilight's
`http-proxy` instead of connecting to a proxy, which can be configured
with a manual `hyper` client.

`error::UrlError`'s `UrlParsing` variant has been removed as it can no
longer occur. `error::Error`'s `BuildingClient` has been removed as
building clients can no longer fail. All Weqwest errors are now `hyper`
errors.

A couple of re-exports have been removed. Use
`twilight_model::user::CurrentUserGuild` instead of
`request::user::get_current_user_guilds::CurrentUserGuild`.
Additionally, use `request::channel::allowed_mentions` instead of
`request::channel::message::allowed_mentions`.

Remove old re-exports that were deprecated in v0.2 ([#673] - [@vivian]).

Upgrade from `tokio` v0.2 to v1 ([#664] - [@vivian]).

`reqwest` has been switched out for `hyper` 0.14. With this comes some
API breakage:

- `client::ClientBuilder::build` no longer returns a `Result`
- `client::ClientBuilder::reqwest_client` has been renamed to
`hyper_client`
- `client::ClientBuilder::{proxy_http, proxy}` have been combined into
`proxy`
- `client::Client::raw` now returns a `hyper` response instead of a
`reqwest` response
- `error::Error::BuildingClient` has been removed
- `error::Error::{ChunkingResponse, RequestError}` now include `hyper`
source errors instead of `reqwest` ones
- `request::channel::message::CreateMessage::attachment{,s}` now takes
`impl Into<Vec<u8>>` instead of `impl Into<reqwest::Body>`

([#657] - [@vivian], [#670] - [@Gelbpunkt]).

Remove `client::Client::add_role` ([#669] - [@vivian]).

Remove webhook URL variant client methods and move webhook URL parsing
to `twilight-util` ([#658] - [@vivian]).

[@Gelbpunkt]: https://github.com/Gelbpunkt
[@vivian]: https://github.com/vivian
[#673]: #673
[#670]: #670
[#669]: #669
[#664]: #664
[#658]: #658
[#657]: #657

Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
zeylahellyer added a commit that referenced this pull request Jan 8, 2021
Version 0.3 has been released with the primary intent to upgrade to
Tokio 1.0.

Upgrade Path

When using `shard::Sink` pass in the new `shard::raw_message::Message`
type instead of `tungstenite::Message`. This is mostly equivalent to
`tungstenite`'s message but prevents exposing it directly, which avoids
API breakage when upgrading internal websocket dependencies.

Changes

Hide the `tungstenite` dependency from the public API by creating an
equivalent to a websocket message that can be constructed and passed in
([#667] - [@vivian]).

Upgrade `tokio` from v0.2 to v1 ([#664] - [@vivian]).

[@vivian]: https://github.com/vivian
[#667]: #667
[#664]: #664

Signed-off-by: Vivian Hellyer <vivian@hellyer.dev>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
c-gateway Affects the gateway crate c-gateway-queue Affects the gateway queue crate c-http Affects the http crate c-lavalink Affects the lavalink crate m-breaking change Breaks the public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Tokio 1.0 checklist
4 participants