Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bigbv/tokio-beanstalkd
Asynchronous client library for interacting with the Beanstalkd work queue.
https://github.com/bigbv/tokio-beanstalkd
beanstalkd rust rust-library tokio
Last synced: 4 months ago
JSON representation
Asynchronous client library for interacting with the Beanstalkd work queue.
- Host: GitHub
- URL: https://github.com/bigbv/tokio-beanstalkd
- Owner: bIgBV
- License: mit
- Created: 2018-09-03T15:47:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-01T17:43:11.000Z (about 1 year ago)
- Last Synced: 2024-10-08T23:05:15.033Z (4 months ago)
- Topics: beanstalkd, rust, rust-library, tokio
- Language: Rust
- Homepage:
- Size: 90.8 KB
- Stars: 14
- Watchers: 1
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tokio-beanstalkd
This crate provides a client for working with [Beanstalkd](https://beanstalkd.github.io/), a simple
fast work queue.[![Build Status](https://travis-ci.org/bIgBV/tokio-beanstalkd.svg?branch=master)](https://travis-ci.org/bIgBV/tokio-beanstalkd)
[![Crates.io](https://img.shields.io/crates/v/tokio-beanstalkd.svg)](https://crates.io/crates/tokio-beanstalkd)
[![Documentation](https://docs.rs/tokio-beanstalkd/badge.svg)](https://docs.rs/tokio-beanstalkd/)This crate provides a client for working with [Beanstalkd](https://beanstalkd.github.io/), a simple
fast work queue.# About Beanstalkd
Beanstalkd is a simple fast work queue. It works at the TCP connection level, considering each TCP
connection individually. A worker may have multiple connections to the Beanstalkd server and each
connection will be considered separate.The protocol is ASCII text based but the data itself is just a bytestream. This means that the
application is responsible for interpreting the data.## Operation
This library can serve as a client for both the application and the worker. The application would
[Beanstalkd::put] jobs on the queue and the workers can [Beanstalkd::reserve]
them. Once they are done with the job, they have to [Beanstalkd::delete] job.
This is required for every job, or else Beanstalkd will not remove it fromits internal datastructres.If a worker cannot finish the job in it's TTR (Time To Run), then it can [Beanstalkd::release]
the job. The application can use the [Beanstalkd::using] method to put jobs in a specific tube,
and workers can use [Beanstalkd::watch]## Interaction with Tokio
The futures in this crate expect to be running under a `tokio::Runtime`. In the common case,
you cannot resolve them solely using `.wait()`, but should instead use `tokio::run` or
explicitly create a `tokio::Runtime` and then use `Runtime::block_on`.An simple example client could look something like this:
```rust
# use tokio_beanstalkd::*;
#[tokio::main]
async fn main() {
let mut bean = Beanstalkd::connect(
&"127.0.0.1:11300"
.parse()
.expect("Unable to connect to Beanstalkd"),
)
.await
.unwrap();bean.put(0, 1, 100, &b"update:42"[..]).await.unwrap();
// Use a particular tube
bean.using("notifications").await.unwrap();
bean.put(0, 1, 100, &b"notify:100"[..]).await.unwrap();
}
```And a worker could look something like this:
```rust
# use tokio_beanstalkd::*;
#[tokio::main]
async fn main() {
let mut bean = Beanstalkd::connect(
&"127.0.0.1:11300"
.parse()
.expect("Unable to connect to Beanstalkd"),
)
.await
.unwrap();let response = bean.reserve().await.unwrap();
// ... do something with the response ...
// Delete the job once it is done
bean.delete(response.id).await.unwrap();
}
```