beanstalkc 0.2.0

Yet another simple Beanstalkd client for Rust.
Documentation

Beanstalkd Client for Rust

Beanstalkd is a fast, general-purpose work queue. beanstalkc-rust is a Beanstalkd Client to communicate with Beanstalkd Server based on the protocol defined here.

Inspired by rust-beanstalkd and beanstalkc.

Why Another ONE

Several repos can be found from here, why not just using one of those directly? The reasons are as follows:

  1. Some of them were poorly documented.
  2. Some of them were not actively developed or maintained.
  3. This rust-beanstalkd repo with the most stars was already out-dated, since not all the beanstalkd commands were supported.

Features

  1. Easy to use.
  2. Support custom connection timeout.
  3. Support all the commands defined in the protocol.txt.
  4. Well documented.

Documentation

Full documentation can be found here.

Usage

Full example can be found here.

Producer

use beanstalkc::Beanstalkc;
use std::time;

fn main() {
    let mut conn = Beanstalkc::new()
        .host("127.0.0.1")
        .port(11300)
        .connection_timeout(Some(time::Duration::from_secs(10)))
        .connect()
        .expect("connection failed");

    conn.use_tube("jobs").unwrap();
    conn.put_default(b"hello, world").unwrap();
}

Consumer

use beanstalkc::Beanstalkc;
use std::time;

fn main() {
    let mut conn = Beanstalkc::new()
        .host("127.0.0.1")
        .port(11300)
        .connection_timeout(Some(time::Duration::from_secs(10)))
        .connect()
        .expect("connection failed");

    conn.watch("jobs").unwrap();
    let job = conn.reserve().expect("failed to reserve job");
    job.delete().expect("failed to delete job");
}

TODO

  • More unit tests.

License

Licensed under the MIT license

Contribution

Please feel free to report any issues~