Prepare jobs-sled for release

This commit is contained in:
asonix 2019-09-22 12:41:13 -05:00
parent 7e06ad981f
commit a5b2a3e8dd
4 changed files with 22 additions and 5 deletions

View file

@ -30,6 +30,6 @@ path = "jobs-actix"
optional = true
[dependencies.background-jobs-sled-storage]
version = "0.1.3"
version = "0.2.0"
path = "jobs-sled"
optional = true

View file

@ -1,7 +1,6 @@
use actix::System;
use background_jobs::{Backoff, Job, MaxRetries, Processor, ServerConfig, WorkerConfig};
use failure::Error;
use futures::{future::ok, Future};
use serde_derive::{Deserialize, Serialize};
const DEFAULT_QUEUE: &'static str = "default";
@ -76,11 +75,12 @@ impl MyJob {
impl Job for MyJob {
type Processor = MyProcessor;
type State = MyState;
type Future = Result<(), Error>;
fn run(self, state: MyState) -> Box<dyn Future<Item = (), Error = Error> + Send> {
fn run(self, state: MyState) -> Self::Future {
println!("{}: args, {:?}", state.app_name, self);
Box::new(ok(()))
Ok(())
}
}

View file

@ -1,7 +1,7 @@
[package]
name = "background-jobs-sled-storage"
description = "Sled storage backend for background-jobs"
version = "0.1.3"
version = "0.2.0"
license-file = "../LICENSE"
authors = ["asonix <asonix@asonix.dog>"]
repository = "https://git.asonix.dog/Aardwolf/background-jobs"

View file

@ -1,3 +1,18 @@
#![deny(missing_docs)]
//! # Background Jobs Sled Storage
//! _An implementation of the Background Jobs Storage trait based on the Sled embedded database_
//!
//! ### Usage
//! ```rust
//! use background_jobs::{ServerConfig, sled_storage::Storage};
//! use sled_extensions::{ConfigBuilder, Db};
//!
//! let db = Db::start(ConfigBuilder::default().temporary(true).build())?;
//! let storage = Storagege::new(db)?;
//! let queue_handle = ServerConfig::new(storage).thread_count(8).start();
//! ```
use background_jobs_core::{JobInfo, Stats, Storage};
use chrono::offset::Utc;
use sled_extensions::{bincode::Tree, cbor, Db, DbExt};
@ -5,6 +20,7 @@ use sled_extensions::{bincode::Tree, cbor, Db, DbExt};
pub use sled_extensions::{Error, Result};
#[derive(Clone)]
/// The Sled-backed storage implementation
pub struct SledStorage {
jobinfo: cbor::Tree<JobInfo>,
running: Tree<u64>,
@ -108,6 +124,7 @@ impl Storage for SledStorage {
}
impl SledStorage {
/// Create a new Storage struct
pub fn new(db: Db) -> Result<Self> {
Ok(SledStorage {
jobinfo: db.open_cbor_tree("background-jobs-jobinfo")?,