Преглед на файлове

Merge pull request #1406 from apiraino/update-tokio-runtime

Update Tokio runtime
Mark Rousskov преди 3 години
родител
ревизия
606bffb4bb
променени са 10 файла, в които са добавени 166 реда и са изтрити 331 реда
  1. 147 314
      Cargo.lock
  2. 6 6
      Cargo.toml
  3. 1 1
      src/bin/lang-agenda.rs
  4. 1 1
      src/bin/prioritization-agenda.rs
  5. 1 1
      src/db.rs
  6. 2 2
      src/github.rs
  7. 1 1
      src/handlers/github_releases.rs
  8. 2 1
      src/handlers/glacier.rs
  9. 3 2
      src/main.rs
  10. 2 2
      src/triage.rs

Файловите разлики са ограничени, защото са твърде много
+ 147 - 314
Cargo.lock


+ 6 - 6
Cargo.toml

@@ -10,7 +10,7 @@ edition = "2018"
 serde_json = "1"
 openssl = "0.10"
 dotenv = "0.15"
-reqwest = { version = "0.10", features = ["json", "blocking"] }
+reqwest = { version = "0.11.4", features = ["json", "blocking"] }
 regex = "1"
 lazy_static = "1"
 log = "0.4"
@@ -21,19 +21,19 @@ parser = { path = "parser" }
 rust_team_data = { git = "https://github.com/rust-lang/team" }
 glob = "0.3.0"
 toml = "0.5.1"
-hyper = "0.13"
-tokio = { version = "0.2", features = ["macros", "time"] }
+hyper = { version = "0.14.4", features = ["server", "stream"]}
+tokio = { version = "1.7.1", features = ["macros", "time", "rt"] }
 futures = { version = "0.3", default-features = false, features = ["std"] }
 async-trait = "0.1.31"
 uuid = { version = "0.8", features = ["v4"] }
 url = "2.1.0"
 once_cell = "1"
 chrono = { version = "0.4", features = ["serde"] }
-tokio-postgres = { version = "0.5", features = ["with-chrono-0_4"] }
-postgres-native-tls = "0.3"
+tokio-postgres = { version = "0.7.2", features = ["with-chrono-0_4"] }
+postgres-native-tls = "0.5.0"
 native-tls = "0.2"
 serde_path_to_error = "0.1.2"
-octocrab = "0.5"
+octocrab = "0.9.1"
 comrak = "0.8.2"
 route-recognizer = "0.3.0"
 

+ 1 - 1
src/bin/lang-agenda.rs

@@ -1,6 +1,6 @@
 use triagebot::{agenda, logger};
 
-#[tokio::main]
+#[tokio::main(flavor = "current_thread")]
 async fn main() {
     dotenv::dotenv().ok();
     logger::init();

+ 1 - 1
src/bin/prioritization-agenda.rs

@@ -1,6 +1,6 @@
 use triagebot::{agenda, logger};
 
-#[tokio::main]
+#[tokio::main(flavor = "current_thread")]
 async fn main() {
     dotenv::dotenv().ok();
     logger::init();

+ 1 - 1
src/db.rs

@@ -36,7 +36,7 @@ pub async fn make_client() -> anyhow::Result<tokio_postgres::Client> {
                 anyhow::bail!("failed to connect to DB: {}", e);
             }
         };
-        tokio::spawn(async move {
+        tokio::task::spawn(async move {
             if let Err(e) = connection.await {
                 eprintln!("database connection error: {}", e);
             }

+ 2 - 2
src/github.rs

@@ -98,7 +98,7 @@ impl GithubClient {
         );
 
         async move {
-            tokio::time::delay_for(sleep).await;
+            tokio::time::sleep(sleep).await;
 
             // check rate limit
             let rate_resp = self
@@ -130,7 +130,7 @@ impl GithubClient {
             if rate_limit.remaining == 0 {
                 let sleep = Self::calc_sleep(rate_limit.reset);
                 if sleep > 0 {
-                    tokio::time::delay_for(Duration::from_secs(sleep)).await;
+                    tokio::time::sleep(Duration::from_secs(sleep)).await;
                 }
             }
 

+ 1 - 1
src/handlers/github_releases.rs

@@ -95,7 +95,7 @@ pub(super) async fn handle(
             }
 
             log::debug!("sleeping for one second to avoid hitting any rate limit");
-            tokio::time::delay_for(Duration::from_secs(1)).await;
+            tokio::time::sleep(Duration::from_secs(1)).await;
         } else {
             log::trace!(
                 "skipping tag {} since it doesn't have a changelog entry",

+ 2 - 1
src/handlers/glacier.rs

@@ -2,7 +2,8 @@
 
 use crate::{config::GlacierConfig, github::Event, handlers::Context};
 
-use octocrab::models::Object;
+use models::repos::Object;
+use octocrab::models;
 use octocrab::params::repos::Reference;
 use parser::command::glacier::GlacierCommand;
 

+ 3 - 2
src/main.rs

@@ -1,7 +1,8 @@
 #![allow(clippy::new_without_default)]
 
 use anyhow::Context as _;
-use futures::{future::FutureExt, stream::StreamExt};
+use futures::future::FutureExt;
+use futures::StreamExt;
 use hyper::{header, Body, Request, Response, Server, StatusCode};
 use reqwest::Client;
 use route_recognizer::Router;
@@ -231,7 +232,7 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> {
     Ok(())
 }
 
-#[tokio::main]
+#[tokio::main(flavor = "current_thread")]
 async fn main() {
     dotenv::dotenv().ok();
     logger::init();

+ 2 - 2
src/triage.rs

@@ -43,7 +43,7 @@ pub async fn pulls(
     let mut base_pulls = page.take_items();
     let mut next_page = page.next;
     while let Some(mut page) = octocrab
-        .get_page::<octocrab::models::PullRequest>(&next_page)
+        .get_page::<octocrab::models::pulls::PullRequest>(&next_page)
         .await
         .unwrap()
     {
@@ -119,7 +119,7 @@ pub async fn pulls(
 #[derive(Serialize)]
 struct PullRequest {
     pub html_url: Url,
-    pub number: i64,
+    pub number: u64,
     pub title: String,
     pub assignee: String,
     pub updated_at: String,

Някои файлове не бяха показани, защото твърде много файлове са промени