jonhoo / faktory-rs

Rust bindings for Faktory clients and workers
Apache License 2.0
205 stars 16 forks source link

Using async handlers on the main branch #77

Closed jcaffey closed 1 month ago

jcaffey commented 4 months ago

First of all, thanks @jonhoo for all your open source contributions and education your provide on youtube. I'm your biggest fan boy.

Our team just added faktory to our stack for a new project and we need to use sqlx (async) functions in our handler's run function. Right now we are on 0.12.5 of faktory-rs. The handler trait defined run as sync, so I'm stuck at the moment. Is there a recommended way around this?

I see the main branch supports async. Is this branch close to a release? I'm fine with specifying a commit for faktory-rs in our Cargo.toml that supports async, but wanted to check here first. Are there any known issues?

Thanks again!

RigoOnRails commented 4 months ago

Wondering about this too. I've been keeping track of @rustworthy's async migration work over the past few months & was excited to see the updated README this morning. Would love to be able to use this finally!

rustworthy commented 4 months ago

Wondering about this too. I've been keeping track of @rustworthy's async migration work over the past few months & was excited to see the updated README this morning. Would love to be able to use this finally!

we are almost there..

Btw, thanks for mentioning README - we should remember to update it a bit, since - after some changes suggested by Jon - we can use a more idiomatic and ergonomic chaining, like:

let worker = Worker::builder()
    .register(...)
    .register(...) // however many times
    .register_fn(...) // if you got function handler
    .register_blocking_fn() // for sync function handlers, to facilitate a bit the migration and also for CPU-intensive tasks
    .connect(None)
    .await
    .unwrap();

See a working example

I am also super excited about this release :rocket:

RigoOnRails commented 4 months ago

@rustworthy Thank you so much for all your hard work!

rustworthy commented 1 month ago

This is now available in 0.13.0