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 Tokio to version 0.3 #401

Merged
merged 3 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ version = "0.17.0-rc2"
version = "0.17.0-rc2"

[dev-dependencies]
tokio = { version = "0.2", features = ["macros"] }
tokio = { version = "0.3", features = ["macros"] }
subtle-encoding = { version = "0.5" }
3 changes: 1 addition & 2 deletions relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ authors = [
[dependencies]
relayer = { path = "../relayer" }
ibc = { path = "../modules" }
abscissa_tokio = "0.5.1"
anomaly = "0.2.0"
gumdrop = "0.7"
serde = { version = "1", features = ["serde_derive"] }
thiserror = "1"
tokio = { version = "0.2.13", features = ["rt-util", "sync"] }
tokio = { version = "0.3", features = ["rt", "rt-multi-thread", "time", "stream", "sync"] }
tracing = "0.1.13"
tracing-subscriber = "0.2.3"
futures = "0.3.5"
Expand Down
6 changes: 1 addition & 5 deletions relayer-cli/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ impl Application for CliApp {
/// beyond the default ones provided by the framework, this is the place
/// to do so.
fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> {
use abscissa_tokio::TokioComponent;

let mut components = self.framework_components(command)?;
components.push(Box::new(TokioComponent::new()?));

let components = self.framework_components(command)?;
self.state.components.register(components)
}

Expand Down
9 changes: 5 additions & 4 deletions relayer-cli/src/commands/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use abscissa_core::{
application::fatal_error, error::BoxError, tracing::debug, Command, Options, Runnable,
};

use crate::{application::APPLICATION, prelude::*, tasks::event_listener};
use crate::{prelude::*, tasks::event_listener};

#[derive(Command, Debug, Options)]
pub struct ListenCmd {}
Expand All @@ -20,11 +20,12 @@ impl ListenCmd {

impl Runnable for ListenCmd {
fn run(&self) {
abscissa_tokio::run(&APPLICATION, async move {
let rt = tokio::runtime::Runtime::new().unwrap();

rt.block_on(async move {
self.cmd()
.await
.unwrap_or_else(|e| fatal_error(app_reader().deref(), &*e));
})
.unwrap();
});
}
}
9 changes: 5 additions & 4 deletions relayer-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use abscissa_core::{

use relayer::{chain::CosmosSDKChain, config::Config};

use crate::{application::APPLICATION, prelude::*, tasks};
use crate::{prelude::*, tasks};

#[derive(Command, Debug, Options)]
pub struct StartCmd {
Expand All @@ -23,12 +23,13 @@ impl StartCmd {

impl Runnable for StartCmd {
fn run(&self) {
abscissa_tokio::run(&APPLICATION, async move {
let rt = tokio::runtime::Runtime::new().unwrap();

rt.block_on(async move {
self.cmd()
.await
.unwrap_or_else(|e| fatal_error(app_reader().deref(), &*e));
})
.unwrap();
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sled = { version = "0.34.4", features = ["no_metrics", "no_logs"] }
thiserror = "1.0.11"
toml = "0.5"
tracing = "0.1.13"
tokio = "0.2"
tokio = { version = "0.3", features = ["macros"] }
serde_json = { version = "1" }
bytes = "0.6.0"
prost = "0.6.1"
Expand Down
3 changes: 1 addition & 2 deletions relayer/src/util/block_on.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use futures::Future;

/// Spawns a new tokio runtime and use it to block on the given future.
pub fn block_on<F: Future>(future: F) -> F::Output {
tokio::runtime::Builder::new()
.basic_scheduler()
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
Expand Down