some documentation and package changes
This commit is contained in:
parent
d1c583e997
commit
6b57e96e84
|
@ -1,12 +1,12 @@
|
|||
[package]
|
||||
name = "bunbun-worker"
|
||||
version = "0.2.1"
|
||||
description = "An rpc/non-rpc rabbitmq worker library"
|
||||
version = "0.2.2"
|
||||
description = "An rpc/non-rpc AMQP worker library"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0"
|
||||
authors = ["4o1x5 <4o1x5@4o1x5.dev>"]
|
||||
repository = "https://git.4o1x5.dev/4o1x5/bunbun-worker"
|
||||
keywords = ["worker", "rpc", "rabbitmq"]
|
||||
keywords = ["worker", "rpc", "rabbitmq", "amqp"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
|
|
12
README.md
12
README.md
|
@ -1,11 +1,8 @@
|
|||
<center> <h1> BunBun-Worker </h1> </center>
|
||||
|
||||
> ❗ Disclaimer
|
||||
> This crate is still under development, meaning api's may change on every commit...
|
||||
|
||||
# Introduction
|
||||
|
||||
`bunbun-worker` was made to provide a _panic-safe_ multithreaded job-runner server & client for microservices and alike. It supports [RPC](https://wikipedia.org/wiki/Remote_procedure_call) and regular (non-rpc) calls. As of right now only [rabbitmq](https://www.rabbitmq.com/) is supported but [gRPC](https://grpc.io/) will be added too.
|
||||
`bunbun-worker` is a bare-bone simple multithreaded worker & client library.
|
||||
The creator of this crate recommends against using this library in production as it's a rather a proof of concept. If you intend to use RPC, I highly recommend using a crate like [tonic](https://crates.io/crates/tonic).
|
||||
|
||||
### Rpc
|
||||
|
||||
|
@ -168,11 +165,6 @@ let result = client
|
|||
.unwrap();
|
||||
```
|
||||
|
||||
# Limitations
|
||||
|
||||
1. Currently some `unwrap()`'s are called inside the code and may results in panics (not in the job-runner).
|
||||
2. limited API
|
||||
|
||||
# Bugs department
|
||||
|
||||
Since the code is hosted on a private git instance (as of right now) any bugs shall be discussed in [4o1x5's project room](https://matrix.to/#/#projects:4o1x5.dev).
|
||||
|
|
|
@ -24,7 +24,7 @@ pub struct Client {
|
|||
// TODO implement tls
|
||||
|
||||
impl Client {
|
||||
/// Creates an rpc client
|
||||
/// Creates an `bunbun-worker` client.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -72,7 +72,6 @@ impl Client {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
// TODO handle errors
|
||||
tracing::debug!(
|
||||
"Creating consumer to listen for error/result messages {}",
|
||||
callback_queue.name()
|
||||
|
@ -137,7 +136,6 @@ impl Client {
|
|||
error,
|
||||
now.elapsed()
|
||||
);
|
||||
// Idk if i should nack it?
|
||||
return Err(ClientError::FailedDecode);
|
||||
}
|
||||
Ok(del) => {
|
||||
|
@ -292,6 +290,7 @@ pub struct BasicCallOptions {
|
|||
message_version: String,
|
||||
}
|
||||
impl BasicCallOptions {
|
||||
/// Create a default BasicCallOptions object by using a queue name.
|
||||
pub fn default(queue_name: impl Into<String>) -> Self {
|
||||
Self {
|
||||
timeout: None,
|
||||
|
@ -299,10 +298,12 @@ impl BasicCallOptions {
|
|||
message_version: "v1.0.0".into(),
|
||||
}
|
||||
}
|
||||
/// Set the version of the message, by appending `message_version` after `queue_name`
|
||||
pub fn message_version(mut self, message_version: impl Into<String>) -> Self {
|
||||
self.message_version = message_version.into();
|
||||
self
|
||||
}
|
||||
/// Set the timeout interval on how long the client shall listen to on the callback queue.
|
||||
pub fn timeout(mut self, timeout: Duration) -> Self {
|
||||
self.timeout = Some(timeout);
|
||||
self
|
||||
|
|
23
src/lib.rs
23
src/lib.rs
|
@ -109,7 +109,7 @@ impl WorkerConfig {
|
|||
}
|
||||
}
|
||||
|
||||
/// A worker configuration
|
||||
/// A listener's configuration.
|
||||
|
||||
pub struct ListenerConfig {
|
||||
prefetch_count: u16,
|
||||
|
@ -720,27 +720,6 @@ impl Display for ResultHeader {
|
|||
}
|
||||
}
|
||||
|
||||
async fn create_consumer(
|
||||
channel: Channel,
|
||||
queue_name: &str,
|
||||
consumer_tag: &str,
|
||||
prefect_count: u16,
|
||||
) -> Result<Consumer, lapin::Error> {
|
||||
let channel = channel.clone();
|
||||
channel
|
||||
.basic_qos(prefect_count, BasicQosOptions::default())
|
||||
.await?;
|
||||
|
||||
channel
|
||||
.basic_consume(
|
||||
queue_name,
|
||||
consumer_tag,
|
||||
BasicConsumeOptions::default(),
|
||||
FieldTable::default(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn set_consumer_qos(channel: &mut Channel, prefetch_count: u16) -> Result<(), lapin::Error> {
|
||||
channel
|
||||
.basic_qos(prefetch_count, BasicQosOptions::default())
|
||||
|
|
Loading…
Reference in a new issue