3 unstable releases
Uses old Rust 2015
0.1.0 | Dec 12, 2015 |
---|---|
0.0.2 | Oct 27, 2015 |
0.0.1 | Oct 25, 2015 |
#39 in #orchestration
25KB
579 lines
Marid
A process orchestration library for running simple, composable threads of work. Inspired by the Ifrit golang library.
lib.rs
:
Marid
A process orchestration library.
This library is influenced by tedsuo's ifrit, a similar library for Golang.
The foundation of the library is built on the idea of a Runner
trait, which
encapsulates a singular unit of work, e.g. a thread, which is has a long lifetime, potentially
forever. The Process
is a trait that defines the actual running of one or more Runner
objects. Importantly, a Process
defines the ability to wait for, and signal a
Runner
.
Examples
use marid::{launch, Runner, Process, Composer, FnRunner, Signal};
let mut runner1 = Box::new(FnRunner::new(move |_sig| {
// Do a bunch of work...
Ok(())
})) as Box<Runner + Send>;
let mut runner2 = Box::new(FnRunner::new(move |_sig| {
// Do a bunch of other work...
Ok(())
})) as Box<Runner + Send>;
let composer = Composer::new(vec!(runner1, runner2), Signal::INT);
let signals = vec!(Signal::INT, Signal::ALRM);
// Start all Runners in separate threads.
let process = launch(composer, signals);
// Wait until all Runners have been setup.
assert!(process.ready().is_ok());
// Send a shutdown signal to all Runners.
process.signal(Signal::INT);
// Wait until all Runners have finished.
assert!(process.wait().is_ok());
Dependencies
~0.7–1MB
~13K SLoC