Update to actix-rt 2.0.0

This commit is contained in:
asonix 2021-02-03 16:32:56 -06:00
parent 2cb81ee743
commit be513dae1e
9 changed files with 29 additions and 29 deletions

View file

@ -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 <asonix@asonix.dog>"]
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

View file

@ -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"] }
```

View file

@ -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"] }

View file

@ -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 <asonix@asonix.dog>"]
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"] }

View file

@ -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");
}
}
}));
});
}

View file

@ -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(())
}

View file

@ -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<S>(arbiter: &Arbiter, storage: S) -> Self
pub(crate) fn new<S>(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
}

View file

@ -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 <asonix@asonix.dog>"]
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]

View file

@ -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"