From be513dae1e1f5a885f346ad9a5372c65cc343b95 Mon Sep 17 00:00:00 2001 From: asonix Date: Wed, 3 Feb 2021 16:32:56 -0600 Subject: [PATCH] Update to actix-rt 2.0.0 --- Cargo.toml | 6 +++--- README.md | 6 +++--- examples/actix-example/Cargo.toml | 4 ++-- jobs-actix/Cargo.toml | 8 ++++---- jobs-actix/src/every.rs | 4 ++-- jobs-actix/src/lib.rs | 14 +++++++------- jobs-actix/src/server.rs | 8 ++++---- jobs-core/Cargo.toml | 6 +++--- jobs-sled/Cargo.toml | 2 +- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3a197a0..15322af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "background-jobs" description = "Background Jobs implemented with actix and futures" -version = "0.8.0" +version = "0.9.0" license-file = "LICENSE" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/background-jobs" @@ -21,10 +21,10 @@ members = [ default = ["background-jobs-actix"] [dependencies.background-jobs-core] -version = "0.8.0" +version = "0.9.0" path = "jobs-core" [dependencies.background-jobs-actix] -version = "0.8.0" +version = "0.9.0" path = "jobs-actix" optional = true diff --git a/README.md b/README.md index 578ba33..bfe41c4 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,10 @@ might not be the best experience. #### Add Background Jobs to your project ```toml [dependencies] -actix = "0.10.0-alpha.0" -background-jobs = "0.8.0-alpha.1" +actix-rt = "2.0.0" +background-jobs = "0.9.0" anyhow = "1.0" -futures = "0.3.4" +futures = "0.3" serde = { version = "1.0", features = ["derive"] } ``` diff --git a/examples/actix-example/Cargo.toml b/examples/actix-example/Cargo.toml index 42b4c66..aa5e9df 100644 --- a/examples/actix-example/Cargo.toml +++ b/examples/actix-example/Cargo.toml @@ -7,10 +7,10 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -actix-rt = "1.0.0" +actix-rt = "2.0.0" anyhow = "1.0" async-trait = "0.1.24" -background-jobs = { version = "0.8.0", path = "../.." } +background-jobs = { version = "0.9.0", path = "../.." } env_logger = "0.7" futures = "0.3" serde = { version = "1.0", features = ["derive"] } diff --git a/jobs-actix/Cargo.toml b/jobs-actix/Cargo.toml index ffe51f9..d828aea 100644 --- a/jobs-actix/Cargo.toml +++ b/jobs-actix/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "background-jobs-actix" description = "in-process jobs processor based on Actix" -version = "0.8.1" +version = "0.9.0" license-file = "../LICENSE" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/background-jobs" @@ -10,11 +10,11 @@ readme = "../README.md" edition = "2018" [dependencies] -actix-rt = "1.1.1" +actix-rt = "2.0.0" anyhow = "1.0" async-mutex = "1.0.1" async-trait = "0.1.24" -background-jobs-core = { version = "0.8.0", path = "../jobs-core", features = ["with-actix"] } +background-jobs-core = { version = "0.9.0", path = "../jobs-core", features = ["with-actix"] } chrono = "0.4" log = "0.4" num_cpus = "1.10.0" @@ -22,5 +22,5 @@ rand = "0.7.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" -tokio = { version = "0.2.22", default-features = false, features = ["sync"] } +tokio = { version = "1", default-features = false, features = ["sync"] } uuid = { version ="0.8.1", features = ["v4", "serde"] } diff --git a/jobs-actix/src/every.rs b/jobs-actix/src/every.rs index acc3b66..6fe6d4d 100644 --- a/jobs-actix/src/every.rs +++ b/jobs-actix/src/every.rs @@ -14,7 +14,7 @@ where J: Job + Clone + Send, { let spawner_clone = spawner.clone(); - spawner.arbiter.send(Box::pin(async move { + spawner.arbiter.spawn(async move { let mut interval = interval_at(Instant::now(), duration); loop { @@ -24,5 +24,5 @@ where error!("Failed to queue job"); } } - })); + }); } diff --git a/jobs-actix/src/lib.rs b/jobs-actix/src/lib.rs index bdf1442..4e0addc 100644 --- a/jobs-actix/src/lib.rs +++ b/jobs-actix/src/lib.rs @@ -116,7 +116,7 @@ //! } //! ``` -use actix_rt::Arbiter; +use actix_rt::{Arbiter, ArbiterHandle}; use anyhow::Error; use background_jobs_core::{new_job, new_scheduled_job, Job, ProcessorMap, Stats, Storage}; use chrono::{DateTime, Utc}; @@ -228,7 +228,7 @@ where let processors = self.processors.clone(); let server = queue_handle.inner.clone(); - arbiter.exec_fn(move || { + arbiter.spawn_fn(move || { local_worker(key, processors.cached(), server); }); } @@ -243,7 +243,7 @@ where #[derive(Clone)] pub struct QueueHandle { inner: Server, - arbiter: Arbiter, + arbiter: ArbiterHandle, } impl QueueHandle { @@ -257,11 +257,11 @@ impl QueueHandle { { let job = new_job(job)?; let server = self.inner.clone(); - self.arbiter.send(Box::pin(async move { + self.arbiter.spawn(async move { if let Err(e) = server.new_job(job).await { error!("Error creating job, {}", e); } - })); + }); Ok(()) } @@ -275,11 +275,11 @@ impl QueueHandle { { let job = new_scheduled_job(job, after)?; let server = self.inner.clone(); - self.arbiter.send(Box::pin(async move { + self.arbiter.spawn(async move { if let Err(e) = server.new_job(job).await { error!("Error creating job, {}", e); } - })); + }); Ok(()) } diff --git a/jobs-actix/src/server.rs b/jobs-actix/src/server.rs index 53dfeb3..d51806b 100644 --- a/jobs-actix/src/server.rs +++ b/jobs-actix/src/server.rs @@ -4,7 +4,7 @@ use crate::{ }; use actix_rt::{ time::{interval_at, Instant}, - Arbiter, + ArbiterHandle, }; use anyhow::Error; use async_mutex::Mutex; @@ -35,7 +35,7 @@ pub(crate) struct Server { impl Server { /// Create a new Server from a compatible storage implementation - pub(crate) fn new(arbiter: &Arbiter, storage: S) -> Self + pub(crate) fn new(arbiter: &ArbiterHandle, storage: S) -> Self where S: Storage + Sync + 'static, { @@ -45,7 +45,7 @@ impl Server { }; let server2 = server.clone(); - arbiter.send(Box::pin(async move { + arbiter.spawn(async move { let mut interval = interval_at(Instant::now(), Duration::from_secs(1)); loop { @@ -54,7 +54,7 @@ impl Server { error!("Error while checking database for new jobs, {}", e); } } - })); + }); server2 } diff --git a/jobs-core/Cargo.toml b/jobs-core/Cargo.toml index 8b50eb5..abbc5c2 100644 --- a/jobs-core/Cargo.toml +++ b/jobs-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "background-jobs-core" description = "Core types for implementing an asynchronous jobs processor" -version = "0.8.0" +version = "0.9.0" license-file = "../LICENSE" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/background-jobs" @@ -14,7 +14,7 @@ default = [] with-actix = ["actix-rt", "tokio"] [dependencies] -actix-rt = { version = "1.1.1", optional = true } +actix-rt = { version = "2.0.0", optional = true } anyhow = "1.0" async-mutex = "1.0.1" async-trait = "0.1.24" @@ -23,7 +23,7 @@ log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" -tokio = { version = "0.2.22", optional = true, default-features = false, features = ["sync"] } +tokio = { version = "1", optional = true, default-features = false, features = ["sync"] } uuid = { version = "0.8.1", features = ["serde", "v4"] } [dev-dependencies] diff --git a/jobs-sled/Cargo.toml b/jobs-sled/Cargo.toml index c913e3c..9dd8c36 100644 --- a/jobs-sled/Cargo.toml +++ b/jobs-sled/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" [dependencies] actix-threadpool = "0.3.1" async-trait = "0.1.24" -background-jobs-core = { version = "0.8.0-alpha.0", path = "../jobs-core" } +background-jobs-core = { version = "0.9.0", path = "../jobs-core" } chrono = "0.4" sled-extensions = { version = "0.3.0-alpha.0", features = ["bincode", "cbor"], git = "https://git.asonix.dog/Aardwolf/sled-extensions" } thiserror = "1.0"