Clean examples

This commit is contained in:
asonix 2019-09-22 12:49:28 -05:00
parent a5b2a3e8dd
commit ee5c5723c9
5 changed files with 19 additions and 29 deletions

View file

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

View file

@ -5,7 +5,7 @@ version = "0.2.0"
license-file = "../LICENSE"
authors = ["asonix <asonix@asonix.dog>"]
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

View file

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

View file

@ -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();
//! ```

View file

@ -92,11 +92,15 @@
//! }
//! }
//!
//! impl Job<MyState> for MyJob {
//! fn run(self, state: MyState) -> Box<dyn Future<Item = (), Error = Error> + 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<MyState> 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::<MyProcessor>(MyJob::new(1, 2))?;