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.
Several repositories can be found from here, why not just using one of those directly? The reasons are as follows:
- Some of them were poorly documented;
- Some of them were not actively developed or maintained;
- This rust-beanstalkd repo with the most stars was already out-dated, since not all the beanstalkd commands were supported.
- Easy to use;
- Support custom connection timeout;
- Support all the commands defined in the protocol.txt;
- Well documented.
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"
Full documentation can be found here.
More examples can be found here.
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)
)
}
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();
}
Licensed under the MIT license
Please feel free to report any issues~