Background Jobs
This crate provides tooling required to run some processes asynchronously from a usually synchronous application. The standard example of this is Web Services, where certain things need to be processed, but processing them while a user is waiting for their browser to respond might not be the best experience.
Usage
Add Background Jobs to your project
[]
= "0.1"
= "0.1"
= "0.1"
= "0.1"
To get started with Background Jobs, first you should define a job.
Jobs are a combination of the data required to perform an operation, and the logic of that
operation. They implment the Job
, serde::Serialize
, and serde::DeserializeOwned
.
Next, define a Processor.
Processors are types that define default attributes for jobs, as well as containing some logic
used internally to perform the job. Processors must implement Proccessor
and Clone
.
;
Running jobs
By default, this crate ships with the background-jobs-server
feature enabled. This uses the
background-jobs-server
crate to spin up a Server and Workers, and provides a mechanism for
spawning new jobs.
Starting the job server
use ServerConfig;
use Error;
use queue_set;
Starting the job worker
use WorkerConfig;
use Error;
use ;
Queuing jobs
use SpawnerConfig;
use ;
use ;
Not using a ZeroMQ based client/server model
If you want to create your own jobs processor based on this idea, you can depend on the
background-jobs-core
crate, which provides the LMDB storage, Processor and Job traits, as well as some
other useful types for implementing a jobs processor.
Contributing
Feel free to open issues for anything you find an issue with. Please note that any contributed code will be licensed under the GPLv3.
License
Copyright © 2018 Riley Trautman
Background Jobs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Background Jobs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This file is part of Background Jobs.
You should have received a copy of the GNU General Public License along with Background Jobs. If not, see http://www.gnu.org/licenses/.