2005
e68c88ad60
-made the add methods blocking, - added back prefetch setter - bit of docs and other shenanigans |
||
---|---|---|
src | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
deny.toml | ||
flake.lock | ||
flake.nix | ||
LICENSE | ||
README.md | ||
taplo.toml |
BunBun-Worker
bunbun-worker
is a panic-safe multithreaded job-runner server/client library for rust. It supports RPC and regular (non-rpc) calls. As of right now only rabbitmq is supported but gRPC will be added too.
❗ Disclaimer
This crate is still under development, meaning api's may change on every commit...
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:
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
- ServiceA creates a callback queue that the response shall be sent to.
- ServiceA sends a json job message to an already declared queue on a rabbitmq server.
- ServiceB is listening on that queue for messages and spawns a new thread for each received.
- 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.
Installation
Get directly from crates.io
[dependencies]
bunbun-worker = { version = "0.1.1" }
or get it directly from source
[dependencies]
bunbun-worker = { git = "https://git.4o1x5.dev/4o1x5/bunbun-worker", branch = "master" }
Usage
Message versioning
In this crate message versioning is done by including v1.0.0
or such on the end of the queue name, instead of including it in the headers of a message. This reduces the amount of redelivered messages.
The following example will send a job to a queue named emailjob-v1.0.0
.
let result = client
.rpc_call::<EmailJob>(
EmailJob {
send_to: "someone".into(),
contents: "something".into(),
},
BasicCallOptions::default("emailjob")
.timeout(Duration::from_secs(3))
.message_version("v1.0.0")
)
.await
.unwrap();
Limitations
- Currently some
unwrap()
's are called inside the code and may results in panics (not in the job-runner). - 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.
License
Licensed under GNU AFFERO GENERAL PUBLIC LICENSE
Contribution
Currently this library does not accept any contributors, as it's hosted on a private git server.
Credits
This package was made with the help of-