Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.18 KB

File metadata and controls

61 lines (43 loc) · 1.18 KB

Rusque

Resque compatible worker library for Rust. Inspired by goworker.

Disclaimer

This basically works, with the caveat that a job is currently just an unparsed string of json.

Installation

You can use rustpkg to install rusque:

$ rustpkg install github.com/jsanders/rusque

Usage

Import rusque:

extern mod rusque;

Create a worker function:

fn basic_worker(job: rusque::Job) -> rusque::Result {
  println!("I've been asked to work on {:s}", job.job);
  rusque::Ok
}

Create a worker to handle a list of queues:

let mut worker = rusque::Worker::new(~[~"basic_queue"], basic_worker);

Now work on jobs:

rusque.work()

This will block until an error occurs.

See the whole thing in action! Run:

$ cd examples/basics
$ rustpkg install github.com/jsanders/rusque
$ ruby basics.rb
$ rust run basics.rs &
I've been asked to work on Basic with args ~[~"some", ~"args"]
$ ruby basics.rb
I've been asked to work on Basic with args ~[~"some", ~"args"]
$ ruby basics.rb
I've been asked to work on Basic with args ~[~"some", ~"args"]
$ kill %1