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

Upgrade to Tokio 1.0 #170

Merged
merged 1 commit into from
Jan 21, 2021
Merged

Upgrade to Tokio 1.0 #170

merged 1 commit into from
Jan 21, 2021

Conversation

markmandel
Copy link
Contributor

Upgrade Tokio and dependent libraries to 1.0

Also took the opportunity to bring some naming to consistency when
updating api calls for the change to 1.0

@markmandel markmandel added the kind/cleanup Refactoring code, fixing up documentation, etc label Jan 20, 2021
@markmandel markmandel requested a review from iffyio January 20, 2021 23:01
@google-cla google-cla bot added the cla: yes label Jan 20, 2021
@markmandel
Copy link
Contributor Author

I've got one compilation issue I can't seem to work out:

fn run_receive_loop(
log: Logger,
mut client: AggregatedDiscoveryServiceClient<TonicChannel>,
rpc_rx: mpsc::Receiver<DiscoveryRequest>,
mut resource_handlers: ResourceHandlers,
mut backoff: ExponentialBackoff<SystemClock>,
mut shutdown_rx: watch::Receiver<()>,
) -> JoinHandle<RpcSessionResult> {
tokio::spawn(async move {
let mut response_stream = match client
.stream_aggregated_resources(Request::new(rpc_rx))
.await
{
Ok(response) => response.into_inner(),
Err(err) => return Err(RpcSessionError::Receive(resource_handlers, backoff, err)),
};

error[E0277]: the trait bound `tonic::Request<tokio::sync::mpsc::Receiver<xds::envoy::service::discovery::v3::DiscoveryRequest>>: tonic::IntoStreamingRequest` is not satisfied
   --> src/xds/ads_client.rs:312:46
    |
312 |                 .stream_aggregated_resources(Request::new(rpc_rx))
    |                                              ^^^^^^^^^^^^^^^^^^^^ the trait `tonic::IntoStreamingRequest` is not implemented for `tonic::Request<tokio::sync::mpsc::Receiver<xds::envoy::service::discovery::v3::DiscoveryRequest>>`
    |
    = help: the following implementations were found:
              <tonic::Request<T> as tonic::IntoStreamingRequest>

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.

@iffyio got any ideas? I poked at this for a few hours, and I'm drawing blanks.

For some reason the mspc::Receiver doesn't implement a https://docs.rs/tonic/0.4.0/tonic/trait.IntoStreamingRequest.html? But not matter what I do, I can't seem to get it to become an iterator... which I think should work? I'm stuck on this one 😞

@markmandel
Copy link
Contributor Author

Realised I was running just cargo clippy and not cargo clippy --tests - this updates the tests 👍

@markmandel
Copy link
Contributor Author

Worked it out 🤸 needed ReceiverStream from tokio-stream crate, and it seems to be compiling now. It was just hiding some more things to tweak!

@markmandel markmandel force-pushed the cleanup/tokio-1.0 branch 2 times, most recently from a83355b to 091e669 Compare January 21, 2021 05:08
@markmandel markmandel marked this pull request as ready for review January 21, 2021 05:14
@markmandel
Copy link
Contributor Author

This should be good for review! That was fun.

Copy link
Collaborator

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

Looks great! 🎉

pub addr: SocketAddr,
/// The sender side, after splitting the opened socket.
pub send: SendHalf,
/// The socket
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// The socket
/// The opened socket

Comment on lines -380 to -381
// Remove initial value from channel.
shutdown_rx.recv().await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yay! I won't miss this pattern 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Me too! 😁

@iffyio
Copy link
Collaborator

iffyio commented Jan 21, 2021

I've got one compilation issue I can't seem to work out:

fn run_receive_loop(
log: Logger,
mut client: AggregatedDiscoveryServiceClient<TonicChannel>,
rpc_rx: mpsc::Receiver<DiscoveryRequest>,
mut resource_handlers: ResourceHandlers,
mut backoff: ExponentialBackoff<SystemClock>,
mut shutdown_rx: watch::Receiver<()>,
) -> JoinHandle<RpcSessionResult> {
tokio::spawn(async move {
let mut response_stream = match client
.stream_aggregated_resources(Request::new(rpc_rx))
.await
{
Ok(response) => response.into_inner(),
Err(err) => return Err(RpcSessionError::Receive(resource_handlers, backoff, err)),
};

error[E0277]: the trait bound `tonic::Request<tokio::sync::mpsc::Receiver<xds::envoy::service::discovery::v3::DiscoveryRequest>>: tonic::IntoStreamingRequest` is not satisfied
   --> src/xds/ads_client.rs:312:46
    |
312 |                 .stream_aggregated_resources(Request::new(rpc_rx))
    |                                              ^^^^^^^^^^^^^^^^^^^^ the trait `tonic::IntoStreamingRequest` is not implemented for `tonic::Request<tokio::sync::mpsc::Receiver<xds::envoy::service::discovery::v3::DiscoveryRequest>>`
    |
    = help: the following implementations were found:
              <tonic::Request<T> as tonic::IntoStreamingRequest>

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.

@iffyio got any ideas? I poked at this for a few hours, and I'm drawing blanks.

For some reason the mspc::Receiver doesn't implement a https://docs.rs/tonic/0.4.0/tonic/trait.IntoStreamingRequest.html? But not matter what I do, I can't seem to get it to become an iterator... which I think should work? I'm stuck on this one

Missed this comment earlier :P will have a look

@iffyio
Copy link
Collaborator

iffyio commented Jan 21, 2021

Worked it out needed ReceiverStream from tokio-stream crate, and it seems to be compiling now. It was just hiding some more things to tweak!

No wait, it was already solved, I confused myself there for a sec 😅

@markmandel
Copy link
Contributor Author

Just tracking potential flakiness:

failures:

---- extensions::filters::local_rate_limit::tests::token_refill_maximum stdout ----
thread 'extensions::filters::local_rate_limit::tests::token_refill_maximum' panicked at 'assertion failed: `(left == right)`
  left: `None`,
 right: `Some(())`', src/extensions/filters/local_rate_limit/mod.rs:265:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- extensions::filters::local_rate_limit::tests::token_exhaustion_and_refill stdout ----
thread 'extensions::filters::local_rate_limit::tests::token_exhaustion_and_refill' panicked at 'assertion failed: `(left == right)`
  left: `None`,
 right: `Some(())`', src/extensions/filters/local_rate_limit/mod.rs:242:9


failures:
    extensions::filters::local_rate_limit::tests::token_exhaustion_and_refill
    extensions::filters::local_rate_limit::tests::token_refill_maximum

Will keep an eye on it, and see how often it pops up.

Upgrade Tokio and dependent libraries to 1.0

Also took the opportunity to bring some naming to consistency when
updating api calls for the change to 1.0
@markmandel markmandel merged commit 368f3f6 into master Jan 21, 2021
@markmandel markmandel deleted the cleanup/tokio-1.0 branch January 26, 2021 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes kind/cleanup Refactoring code, fixing up documentation, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants