Bump deps

This commit is contained in:
asonix 2019-08-31 11:09:26 -05:00
parent 4b2b1fb442
commit 366a328e9f
4 changed files with 21 additions and 19 deletions

View file

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

View file

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

View file

@ -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<Option<JobInfo>> {
@ -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(())

View file

@ -29,14 +29,14 @@ where
}
}
pub(crate) fn set(&self, key: &str, value: T) -> Result<Option<T>> {
pub(crate) fn insert(&self, key: &str, value: T) -> Result<Option<T>> {
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<Option<T>> {
match self.0.del(key)? {
pub(crate) fn remove(&self, key: &str) -> Result<Option<T>> {
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<u8>, T)>;
type Item = Result<(sled::IVec, T)>;
fn next(&mut self) -> Option<Self::Item> {
self.0.next().map(|res| {