11 releases (1 stable)

1.0.0 Oct 2, 2020
0.2.9 Jun 16, 2020
0.2.8 Apr 25, 2020
0.2.7 Feb 18, 2019

#838 in Network programming

Download history 67/week @ 2024-06-14 51/week @ 2024-06-21 61/week @ 2024-06-28 32/week @ 2024-07-05 34/week @ 2024-07-12 15/week @ 2024-07-19 240/week @ 2024-07-26 74/week @ 2024-08-02 55/week @ 2024-08-09 105/week @ 2024-08-16 26/week @ 2024-08-23 56/week @ 2024-08-30 58/week @ 2024-09-06 89/week @ 2024-09-13 50/week @ 2024-09-20 39/week @ 2024-09-27

237 downloads per month
Used in r2d2-beanstalkd

MIT license

50KB
987 lines

Beanstalkd Client for Rust

Build Status

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

Several repositories 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.

Install

Note: :) version 1.x is no longer compatible with the old ones. Job body now returns raw bytes instead of UTF-8 string. Modification can be found here.

Add this dependency to your Cargo.toml~

beanstalkc = "^1.0.0"

Documentation

Full documentation can be found here.

Usage

More examples 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();
    conn.put(
            b"Hello, rust world.",
            0,
            time::Duration::from_secs(100),
            time::Duration::from_secs(1800)
        )
}

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 mut job = conn.reserve().unwrap();
    println!("{:#?}", job.stats());

    job.delete().unwrap();
}

License

Licensed under the MIT license

Contribution

Please feel free to report any issues~

Dependencies

~2MB
~39K SLoC