ayrat555 / fang

Background processing for Rust
https://fang.badykov.com/
MIT License
609 stars 25 forks source link

How can I list tasks in the queue? #121

Closed t56k closed 1 year ago

t56k commented 1 year ago

I'm trying to list all the tasks (both complete and incomplete) in the worker queue, and I haven't managed to find an example anywhere. Is there an established way to do this--preferably in a way that will serialize to JSON?

use fang::fang_tasks::dsl::fang_tasks;

let root = warp::get()
    .and(warp::path::end())
    .map({
        move || index::WithTemplate {
            name: "index.html",
            value: json!({
                "builds": fang_tasks, // what should go here?
            }),
        }
    })
.map(handlebars);

Thanks so much for any help.

ayrat555 commented 1 year ago

Hey.

the project currently doesn't provide such api. the queries will have to be created manually,

it's just a table in the postgres db. so you can use diesel (sync api), or tokio-postgres (async api)

t56k commented 1 year ago

Thanks so much for letting me know. :)