bunbun-worker/README.md

76 lines
2.8 KiB
Markdown
Raw Normal View History

2024-10-24 22:40:48 +02:00
<center> <h1> BunBun-Worker </h1> </center>
2024-10-24 20:42:40 +02:00
2024-11-13 19:57:46 +01:00
`bunbun-worker` is a panic-safe multithreaded job-runner server/client library for rust. 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.
2024-10-24 20:42:40 +02:00
2024-10-24 22:40:48 +02:00
> ❗ Disclaimer
> This crate is still under development, meaning api's may change on every commit...
2024-11-13 19:57:46 +01:00
# Introduction
`bunbun-worker` was made to provide a way for microservices written in rust to communicate to each other by dispatching jobs that may return data and those who don't.
### Rpc
Remote procedure call, as it's name says is a message that can be sent to a remote microservice to be processed and the result to be returned. In `bunbun-worker` it's implemented by the following example:
```mermaid
sequenceDiagram
ServiceA->>+ServiceB: Hey, could you do this job for me?
Note right of ServiceB: ServiceB does the job
ServiceB->>+ServiceA: Sure, here is the data result
```
1. ServiceA creates a callback queue that the response shall be sent to.
2. ServiceA sends a json job message to an **already declared** queue on a rabbitmq server.
3. ServiceB is listening on that queue for messages and spawns a new thread for each received.
4. Once ServiceB has finished the work, using the received messages header it responds to the callback queue with the correlation-id.
### Non-rpc
In `bunbun-worker` regular jobs are called _non-rpc_ jobs, indicating that the response is not awaited.
2024-10-24 22:40:48 +02:00
## Installation
2024-11-13 19:57:46 +01:00
Get directly from crates.io
2024-10-24 22:40:48 +02:00
```toml
[dependencies]
2024-11-13 21:43:08 +01:00
bunbun-worker = { version = "0.1.1" }
2024-10-24 22:40:48 +02:00
```
2024-11-13 19:57:46 +01:00
or get it directly from source
2024-10-24 22:40:48 +02:00
```toml
[dependencies]
2024-11-13 21:37:24 +01:00
bunbun-worker = { git = "https://git.4o1x5.dev/4o1x5/bunbun-worker", branch = "master" }
2024-10-24 22:40:48 +02:00
```
## Usage
Here is a basic implementation of an RPC job in bunbun-worker
2024-11-13 19:57:46 +01:00
# Limitations
1. Currently some `unwrap()`'s are called inside the code and may results in panics (not in the job-runner).
2. No settings, and very limited API
3. The rabbitmq RPC logic is very basic with no message-versioning (aside using different queue names (eg service-class-v1.0.0) )
2024-11-13 19:57:46 +01:00
# 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).
2024-10-24 22:40:48 +02:00
## License
Licensed under [GNU AFFERO GENERAL PUBLIC LICENSE](https://www.gnu.org/licenses/agpl-3.0.en.html)
### Contribution
2024-11-13 19:57:46 +01:00
Currently this library does not accept any contributors, as it's hosted on a private git server.
2024-10-24 22:40:48 +02:00
# Credits
This package was made with the help of-
- [This readme template you are reading right now](https://github.com/webern/cargo-readme/blob/master/README.md)
- [Lapin, an extensive easy to use rabbitmq client](https://crates.io/crates/lapin)