diff --git a/jobs-actix/src/lib.rs b/jobs-actix/src/lib.rs index 7459237..9c83350 100644 --- a/jobs-actix/src/lib.rs +++ b/jobs-actix/src/lib.rs @@ -11,7 +11,7 @@ //! used. By default, the number of cores of the running system is used. //! //! ### Example -//! ```rust +//! ```rust,ignore //! use actix::System; //! use background_jobs::{Backoff, Job, MaxRetries, Processor, ServerConfig, WorkerConfig}; //! use failure::Error; diff --git a/jobs-sled/Cargo.toml b/jobs-sled/Cargo.toml index 55741cc..6999c69 100644 --- a/jobs-sled/Cargo.toml +++ b/jobs-sled/Cargo.toml @@ -5,7 +5,7 @@ version = "0.2.0" license-file = "../LICENSE" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/background-jobs" -readme = "README.md" +readme = "../README.md" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/jobs-sled/README.md b/jobs-sled/README.md deleted file mode 100644 index 7253de9..0000000 --- a/jobs-sled/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Jobs Sled -_a Sled storage backend for background-jobs_ - -This is the default storage backend for the Background Jobs library based on [Sled](https://github.com/spacejam/sled). It also servers as a reference implementation for storage backends. - -### License -This work is licensed under the Cooperative Software License. This is not a Free Software -License, but may be considered a "source-available License." For most hobbyists, self-employed -developers, worker-owned companies, and cooperatives, this software can be used in most -projects so long as this software is distributed under the terms of the CSL. For more -information, see the provided LICENSE file. If none exists, the license can be found online -[here](https://lynnesbian.space/csl/). If you are a free software project and wish to use this -software under the terms of the GNU Affero General Public License, please contact me at -[asonix@asonix.dog](mailto:asonix@asonix.dog) and we can sort that out. If you wish to use this -project under any other license, especially in proprietary software, the answer is likely no. diff --git a/jobs-sled/src/lib.rs b/jobs-sled/src/lib.rs index 54cc014..1a0d039 100644 --- a/jobs-sled/src/lib.rs +++ b/jobs-sled/src/lib.rs @@ -4,12 +4,12 @@ //! _An implementation of the Background Jobs Storage trait based on the Sled embedded database_ //! //! ### Usage -//! ```rust +//! ```rust,ignore //! 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 storage = Storage::new(db)?; //! let queue_handle = ServerConfig::new(storage).thread_count(8).start(); //! ``` diff --git a/src/lib.rs b/src/lib.rs index c5a733a..87ba5c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,11 +92,15 @@ //! } //! } //! -//! impl Job for MyJob { -//! fn run(self, state: MyState) -> Box + Send> { +//! impl Job for MyJob { +//! type Processor = MyProcessor; +//! type State = MyState; +//! type Future = Result<(), Error>; +//! +//! fn run(self, state: Self::State) -> Self::Future { //! info!("{}: args, {:?}", state.app_name, self); //! -//! Box::new(Ok(()).into_future()) +//! Ok(()) //! } //! } //! ``` @@ -113,7 +117,7 @@ //! #[derive(Clone, Debug)] //! pub struct MyProcessor; //! -//! impl Processor for MyProcessor { +//! impl Processor for MyProcessor { //! // The kind of job this processor should execute //! type Job = MyJob; //! @@ -157,8 +161,9 @@ //! ##### Main //! ```rust,ignore //! use actix::System; -//! use background_jobs::{ServerConfig, SledStorage, WorkerConfig}; +//! use background_jobs::{ServerConfig, sled_storage::Storage, WorkerConfig}; //! use failure::Error; +//! use sled::Db; //! //! fn main() -> Result<(), Error> { //! // First set up the Actix System to ensure we have a runtime to spawn jobs on. @@ -166,16 +171,16 @@ //! //! // Set up our Storage //! let db = Db::start_default("my-sled-db")?; -//! let storage = SledStorage::new(db)?; +//! let storage = Storage::new(db)?; //! //! // Start the application server. This guards access to to the jobs store //! let queue_handle = ServerConfig::new(storage).start(); //! //! // Configure and start our workers -//! let mut worker_config = WorkerConfig::new(move || MyState::new("My App")); -//! worker_config.register(MyProcessor); -//! worker_config.set_processor_count(DEFAULT_QUEUE, 16); -//! worker_config.start(queue_handle.clone()); +//! WorkerConfig::new(move || MyState::new("My App")) +//! .register(MyProcessor) +//! .set_processor_count(DEFAULT_QUEUE, 16) +//! .start(queue_handle.clone()); //! //! // Queue our jobs //! queue_handle.queue::(MyJob::new(1, 2))?;