minion

Crates.iominion
lib.rsminion
version0.1.3
sourcesrc
created_at2018-05-20 18:06:05.133695
updated_at2021-07-11 17:23:08.056161
descriptionCrate for managing cancellable services
homepagehttps://github.com/jonhoo/minion
repositoryhttps://github.com/jonhoo/minion.git
max_upload_size
id66364
size28,214
Jon Gjengset (jonhoo)

documentation

README

minion

Crates.io Documentation Build Status

This crate provides a wrapper type for making long-running service loops cancellable.

Let's dive right in with an example. For further details see Cancellable.

// impl Cancellable for Service { .. }
let s = Service::new();

// start the service loop on a new thread
let h = s.spawn();

// get a handle that allows cancelling the service loop
let exit = h.canceller();

// spin up a new thread that will handle exit signals
thread::spawn(move || {
    // this might catch Ctrl-C from the user, wait for a particular packet,
    // or for any other condition that signals that the service should exit
    // cleanly. in this case, we just terminate after a fixed amount of time.
    thread::sleep(time::Duration::from_secs(1));

    // tell the service loop to exit at the first opportunity
    exit.cancel();
});

// block until the service loop exits or errors.
h.wait().unwrap();

Live-coding

The crate is under development as part of a live-coding stream series intended for users who are already somewhat familiar with Rust, and who want to see something larger and more involved be built.

You can find the recordings of past sessions in this YouTube playlist. This crate was made in this video. To get updates about future streams, follow me on Patreon or Twitter.

Thank you

For each of the projects I build, I like to thank the people who are willing and able to take the extra step of supporting me in making these videos on Patreon or Liberapay. You have my most sincere gratitude, and I'm so excited that you find what I do interesting enough that you're willing to give a stranger money to do something they love!

  • Rodrigo Valin
  • Roger Andersen (@hexjelly)
  • Pigeon F
Commit count: 16

cargo fmt