From 366a328e9f10c470ab24929058a5707a2a57a4ac Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 31 Aug 2019 11:09:26 -0500 Subject: [PATCH] Bump deps --- jobs-actix/Cargo.toml | 2 +- jobs-sled/Cargo.toml | 2 +- jobs-sled/src/lib.rs | 26 ++++++++++++++------------ jobs-sled/src/sled_wrappers.rs | 10 +++++----- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/jobs-actix/Cargo.toml b/jobs-actix/Cargo.toml index 2a761e8..8c6745d 100644 --- a/jobs-actix/Cargo.toml +++ b/jobs-actix/Cargo.toml @@ -16,7 +16,7 @@ failure = "0.1" futures = "0.1" log = "0.4" num_cpus = "1.10.0" -rand = "0.6.5" +rand = "0.7.0" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" diff --git a/jobs-sled/Cargo.toml b/jobs-sled/Cargo.toml index 7ae80b2..6f69e8d 100644 --- a/jobs-sled/Cargo.toml +++ b/jobs-sled/Cargo.toml @@ -14,6 +14,6 @@ edition = "2018" background-jobs-core = { version = "0.6", path = "../jobs-core" } chrono = "0.4" failure = "0.1" -sled = "0.24" +sled = "0.26" serde = "1.0" serde_json = "1.0" diff --git a/jobs-sled/src/lib.rs b/jobs-sled/src/lib.rs index 176d256..9cd467a 100644 --- a/jobs-sled/src/lib.rs +++ b/jobs-sled/src/lib.rs @@ -27,7 +27,7 @@ impl Storage for SledStorage { } fn save_job(&mut self, job: JobInfo) -> Result<()> { - self.jobinfo.set(&job_key(job.id()), job).map(|_| ()) + self.jobinfo.insert(&job_key(job.id()), job).map(|_| ()) } fn fetch_job(&mut self, id: u64) -> Result> { @@ -51,7 +51,7 @@ impl Storage for SledStorage { .next(); if let Some(ref job) = job { - queue_tree.del(&job_key(job.id()))?; + queue_tree.remove(&job_key(job.id()))?; } Ok(job) @@ -59,27 +59,29 @@ impl Storage for SledStorage { } fn queue_job(&mut self, queue: &str, id: u64) -> Result<()> { - if let Some(runner_id) = self.running_inverse.del(&job_key(id))? { - self.running.del(&runner_key(runner_id))?; + if let Some(runner_id) = self.running_inverse.remove(&job_key(id))? { + self.running.remove(&runner_key(runner_id))?; } - self.queue.set(&job_key(id), queue.to_owned()).map(|_| ()) + self.queue + .insert(&job_key(id), queue.to_owned()) + .map(|_| ()) } fn run_job(&mut self, id: u64, runner_id: u64) -> Result<()> { - self.queue.del(&job_key(id))?; - self.running.set(&runner_key(runner_id), id)?; - self.running_inverse.set(&job_key(id), runner_id)?; + self.queue.remove(&job_key(id))?; + self.running.insert(&runner_key(runner_id), id)?; + self.running_inverse.insert(&job_key(id), runner_id)?; Ok(()) } fn delete_job(&mut self, id: u64) -> Result<()> { - self.jobinfo.del(&job_key(id))?; - self.queue.del(&job_key(id))?; + self.jobinfo.remove(&job_key(id))?; + self.queue.remove(&job_key(id))?; - if let Some(runner_id) = self.running_inverse.del(&job_key(id))? { - self.running.del(&runner_key(runner_id))?; + if let Some(runner_id) = self.running_inverse.remove(&job_key(id))? { + self.running.remove(&runner_key(runner_id))?; } Ok(()) diff --git a/jobs-sled/src/sled_wrappers.rs b/jobs-sled/src/sled_wrappers.rs index faaec9e..5a4034a 100644 --- a/jobs-sled/src/sled_wrappers.rs +++ b/jobs-sled/src/sled_wrappers.rs @@ -29,14 +29,14 @@ where } } - pub(crate) fn set(&self, key: &str, value: T) -> Result> { + pub(crate) fn insert(&self, key: &str, value: T) -> Result> { let vec = serde_json::to_vec(&value).map_err(|_| Error::Serialize)?; - Ok(self.0.set(key, vec)?.map(move |_| value)) + Ok(self.0.insert(key, vec)?.map(move |_| value)) } - pub(crate) fn del(&self, key: &str) -> Result> { - match self.0.del(key)? { + pub(crate) fn remove(&self, key: &str) -> Result> { + match self.0.remove(key)? { Some(vec) => serde_json::from_slice(&vec) .map_err(|_| Error::Deserialize) .map(Some), @@ -85,7 +85,7 @@ impl<'a, T> Iterator for Iter<'a, T> where T: serde::de::DeserializeOwned, { - type Item = Result<(Vec, T)>; + type Item = Result<(sled::IVec, T)>; fn next(&mut self) -> Option { self.0.next().map(|res| {