Struct json_job_dispatch::Director [−][src]
pub struct Director<'a> { /* fields omitted */ }
Dispatch jobs to registered handlers.
Jobs are sorted into accept
, reject
, and fail
directories based on whether they were
accepted by the relevant handler. Once handled, a .stamp
file containing the timestamp of
when the job was completed is created beside the final location. In addition, rejected and
failed jobs have a .reason
file describing what happened.
Methods
impl<'a> Director<'a>
[src]
impl<'a> Director<'a>
pub fn new(root: &Path) -> Result<Self>
[src]
pub fn new(root: &Path) -> Result<Self>
Creates a new Director
.
The accept
and reject
directories are created as children of the given directory.
pub fn add_handler<K>(&mut self, kind: K, handler: &'a Handler) -> Result<()> where
K: ToString,
[src]
pub fn add_handler<K>(&mut self, kind: K, handler: &'a Handler) -> Result<()> where
K: ToString,
Add a handler for jobs labeled as kind
.
pub fn run_one(&self, path: &Path) -> RunResult
[src]
pub fn run_one(&self, path: &Path) -> RunResult
Handle a single file.
Returns true
if the loop should terminate.
pub fn run(&self, paths: Vec<PathBuf>) -> RunResult
[src]
pub fn run(&self, paths: Vec<PathBuf>) -> RunResult
Handle a batch of files at once.
Returns true
if the loop should terminate.
pub fn watch_directory(&self, path: &Path) -> Result<RunResult>
[src]
pub fn watch_directory(&self, path: &Path) -> Result<RunResult>
Watch a directory for new job files and act upon them.
Upon startup, this searches the directory for existing files. These files are processed in lexigraphic order.