mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2024-11-25 05:21:00 +00:00
Update to actix-rt 2.0.0
This commit is contained in:
parent
2cb81ee743
commit
be513dae1e
9 changed files with 29 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "background-jobs"
|
name = "background-jobs"
|
||||||
description = "Background Jobs implemented with actix and futures"
|
description = "Background Jobs implemented with actix and futures"
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
license-file = "LICENSE"
|
license-file = "LICENSE"
|
||||||
authors = ["asonix <asonix@asonix.dog>"]
|
authors = ["asonix <asonix@asonix.dog>"]
|
||||||
repository = "https://git.asonix.dog/Aardwolf/background-jobs"
|
repository = "https://git.asonix.dog/Aardwolf/background-jobs"
|
||||||
|
@ -21,10 +21,10 @@ members = [
|
||||||
default = ["background-jobs-actix"]
|
default = ["background-jobs-actix"]
|
||||||
|
|
||||||
[dependencies.background-jobs-core]
|
[dependencies.background-jobs-core]
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
path = "jobs-core"
|
path = "jobs-core"
|
||||||
|
|
||||||
[dependencies.background-jobs-actix]
|
[dependencies.background-jobs-actix]
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
path = "jobs-actix"
|
path = "jobs-actix"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
|
@ -13,10 +13,10 @@ might not be the best experience.
|
||||||
#### Add Background Jobs to your project
|
#### Add Background Jobs to your project
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix = "0.10.0-alpha.0"
|
actix-rt = "2.0.0"
|
||||||
background-jobs = "0.8.0-alpha.1"
|
background-jobs = "0.9.0"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
futures = "0.3.4"
|
futures = "0.3"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "2.0.0"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
async-trait = "0.1.24"
|
async-trait = "0.1.24"
|
||||||
background-jobs = { version = "0.8.0", path = "../.." }
|
background-jobs = { version = "0.9.0", path = "../.." }
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "background-jobs-actix"
|
name = "background-jobs-actix"
|
||||||
description = "in-process jobs processor based on Actix"
|
description = "in-process jobs processor based on Actix"
|
||||||
version = "0.8.1"
|
version = "0.9.0"
|
||||||
license-file = "../LICENSE"
|
license-file = "../LICENSE"
|
||||||
authors = ["asonix <asonix@asonix.dog>"]
|
authors = ["asonix <asonix@asonix.dog>"]
|
||||||
repository = "https://git.asonix.dog/Aardwolf/background-jobs"
|
repository = "https://git.asonix.dog/Aardwolf/background-jobs"
|
||||||
|
@ -10,11 +10,11 @@ readme = "../README.md"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = "1.1.1"
|
actix-rt = "2.0.0"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
async-mutex = "1.0.1"
|
async-mutex = "1.0.1"
|
||||||
async-trait = "0.1.24"
|
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"
|
chrono = "0.4"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
num_cpus = "1.10.0"
|
num_cpus = "1.10.0"
|
||||||
|
@ -22,5 +22,5 @@ rand = "0.7.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
thiserror = "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"] }
|
uuid = { version ="0.8.1", features = ["v4", "serde"] }
|
||||||
|
|
|
@ -14,7 +14,7 @@ where
|
||||||
J: Job + Clone + Send,
|
J: Job + Clone + Send,
|
||||||
{
|
{
|
||||||
let spawner_clone = spawner.clone();
|
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);
|
let mut interval = interval_at(Instant::now(), duration);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -24,5 +24,5 @@ where
|
||||||
error!("Failed to queue job");
|
error!("Failed to queue job");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use actix_rt::Arbiter;
|
use actix_rt::{Arbiter, ArbiterHandle};
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use background_jobs_core::{new_job, new_scheduled_job, Job, ProcessorMap, Stats, Storage};
|
use background_jobs_core::{new_job, new_scheduled_job, Job, ProcessorMap, Stats, Storage};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
@ -228,7 +228,7 @@ where
|
||||||
let processors = self.processors.clone();
|
let processors = self.processors.clone();
|
||||||
let server = queue_handle.inner.clone();
|
let server = queue_handle.inner.clone();
|
||||||
|
|
||||||
arbiter.exec_fn(move || {
|
arbiter.spawn_fn(move || {
|
||||||
local_worker(key, processors.cached(), server);
|
local_worker(key, processors.cached(), server);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ where
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct QueueHandle {
|
pub struct QueueHandle {
|
||||||
inner: Server,
|
inner: Server,
|
||||||
arbiter: Arbiter,
|
arbiter: ArbiterHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl QueueHandle {
|
impl QueueHandle {
|
||||||
|
@ -257,11 +257,11 @@ impl QueueHandle {
|
||||||
{
|
{
|
||||||
let job = new_job(job)?;
|
let job = new_job(job)?;
|
||||||
let server = self.inner.clone();
|
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 {
|
if let Err(e) = server.new_job(job).await {
|
||||||
error!("Error creating job, {}", e);
|
error!("Error creating job, {}", e);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,11 +275,11 @@ impl QueueHandle {
|
||||||
{
|
{
|
||||||
let job = new_scheduled_job(job, after)?;
|
let job = new_scheduled_job(job, after)?;
|
||||||
let server = self.inner.clone();
|
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 {
|
if let Err(e) = server.new_job(job).await {
|
||||||
error!("Error creating job, {}", e);
|
error!("Error creating job, {}", e);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use actix_rt::{
|
use actix_rt::{
|
||||||
time::{interval_at, Instant},
|
time::{interval_at, Instant},
|
||||||
Arbiter,
|
ArbiterHandle,
|
||||||
};
|
};
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use async_mutex::Mutex;
|
use async_mutex::Mutex;
|
||||||
|
@ -35,7 +35,7 @@ pub(crate) struct Server {
|
||||||
|
|
||||||
impl Server {
|
impl Server {
|
||||||
/// Create a new Server from a compatible storage implementation
|
/// 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
|
where
|
||||||
S: Storage + Sync + 'static,
|
S: Storage + Sync + 'static,
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ impl Server {
|
||||||
};
|
};
|
||||||
|
|
||||||
let server2 = server.clone();
|
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));
|
let mut interval = interval_at(Instant::now(), Duration::from_secs(1));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -54,7 +54,7 @@ impl Server {
|
||||||
error!("Error while checking database for new jobs, {}", e);
|
error!("Error while checking database for new jobs, {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
server2
|
server2
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "background-jobs-core"
|
name = "background-jobs-core"
|
||||||
description = "Core types for implementing an asynchronous jobs processor"
|
description = "Core types for implementing an asynchronous jobs processor"
|
||||||
version = "0.8.0"
|
version = "0.9.0"
|
||||||
license-file = "../LICENSE"
|
license-file = "../LICENSE"
|
||||||
authors = ["asonix <asonix@asonix.dog>"]
|
authors = ["asonix <asonix@asonix.dog>"]
|
||||||
repository = "https://git.asonix.dog/Aardwolf/background-jobs"
|
repository = "https://git.asonix.dog/Aardwolf/background-jobs"
|
||||||
|
@ -14,7 +14,7 @@ default = []
|
||||||
with-actix = ["actix-rt", "tokio"]
|
with-actix = ["actix-rt", "tokio"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = { version = "1.1.1", optional = true }
|
actix-rt = { version = "2.0.0", optional = true }
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
async-mutex = "1.0.1"
|
async-mutex = "1.0.1"
|
||||||
async-trait = "0.1.24"
|
async-trait = "0.1.24"
|
||||||
|
@ -23,7 +23,7 @@ log = "0.4"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
thiserror = "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"] }
|
uuid = { version = "0.8.1", features = ["serde", "v4"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -13,7 +13,7 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-threadpool = "0.3.1"
|
actix-threadpool = "0.3.1"
|
||||||
async-trait = "0.1.24"
|
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"
|
chrono = "0.4"
|
||||||
sled-extensions = { version = "0.3.0-alpha.0", features = ["bincode", "cbor"], git = "https://git.asonix.dog/Aardwolf/sled-extensions" }
|
sled-extensions = { version = "0.3.0-alpha.0", features = ["bincode", "cbor"], git = "https://git.asonix.dog/Aardwolf/sled-extensions" }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
|
Loading…
Reference in a new issue