From 6b57e96e84a711b50b177e0c799840b3543ed3b2 Mon Sep 17 00:00:00 2001
From: 4o1x5 <4o1x5@4o1x5.dev>
Date: Mon, 25 Nov 2024 06:38:07 +0100
Subject: [PATCH] some documentation and package changes
---
Cargo.toml | 6 +++---
README.md | 12 ++----------
src/client.rs | 7 ++++---
src/lib.rs | 23 +----------------------
4 files changed, 10 insertions(+), 38 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index a75de1f..afc4344 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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]
diff --git a/README.md b/README.md
index 08b8d14..fad4cb7 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,8 @@
BunBun-Worker
-
-> ❗ 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).
diff --git a/src/client.rs b/src/client.rs
index 71d3278..3fa18b6 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -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) -> 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) -> 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
diff --git a/src/lib.rs b/src/lib.rs
index b8f53ab..2a6fb25 100644
--- a/src/lib.rs
+++ b/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 {
- 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())