-
Notifications
You must be signed in to change notification settings - Fork 15
Description
These few years many projects like axum and bevy provide type-safe function like argument, like apalis too.
Lately I have been playing around with these API and have been thinking of something like these.
fn add(x: usize, y: usize) -> usize { // with an optional Job or State at the front
x + y
}
broker.send(add.prepare(1, 2)).await.unwrap();Or this style (but not sure if possible with faktory due to args):
fn add(Args((x, y)): Args<(usize, usize)>) -> usize { // with an optional Job at the front or some other state extractor, type-safe state like axum
x + y
}
broker.send(add.prepare(1, 2)).await.unwrap();With registration of working like this:
fn add(x: usize, y: usize) -> usize { // with an optional Job or State at the front
x + y
}
let worker = Worker::new().register(add); // or optional with_state
faktory::run(worker, &["default"]).await.unwrap();What do you think? I did some some prototypes.
Although faktory is cross-language, but when working within the same language itself, it can help eliminates some bugs.
Looking at reusing parts of tower to provide neat features with layer too.
I was actually looking at apalis, but they don't have a core concept of routing functions, and I came across this project (even when I saw it back then).
After reading the original faktory specification, I felt like faktory have been largely monopolized, less motivated now.