Replies: 1 comment
-
|
I think the best way to discuss your issue is to include an example use case. Because there are several approaches that are usable. Eg Could you explain what you mean by this? What storage are you using? What version.
Possible solutions even without much context:
async fn send_reminder<T: DoSomeWork>(
task: T,
wrk: WorkerContext,
) -> Result<(), BoxDynError> {
task.do_some_work().await
Ok(())
}
let int_worker = WorkerBuilder::new("worker-2")
.backend(int_store)
.build(send_reminder);
let map_worker = WorkerBuilder::new("worker-1")
.backend(map_store)
.build(send_reminder);
tokio::try_join!(int_worker.run(), map_worker.run()).unwrap();
use futures::future::join_all;
let mut store = SharedPostgresStorage::new(pool);
fn build_worker<S: Service<PgTask<T>, T>(store: &mut SharedPostgresStorage, svc: S) -> BoxFuture {
let backend = store.make_shared().unwrap();
WorkerBuilder::new("worker-1")
.backend(backend)
.build(svc)
.run()
.boxed()
}
let workers = Vec::new();
for task in tasks {
workers.push(build_worker(&mut store, task));
}
join_all(workers).await
What does this mean?
What next?I think it will be wise to include concrete examples of these approaches to offer better understanding to this question as it has been raised several times and usually comes back to these three options. If you feel that this does not address your issue effectively I am willing to keep this conversation going :). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Has apalis been used in large projects with hundreds of different kinds of tasks?
The current API design seems to make this kind of usage incredibly awkward, with storage backend carrying around the args generic, and needing to manually start workers for each type.
It also seems like a process processing many different tasks would do an incredibly amount of redundant work while waiting for tasks?
I guess a workaround would be to use an enum for the args , but that would lose a lot of observability and control.
It would seem much more sensible to have an underlying dynamic API that can be used in case the typed API is not desirable.
Beta Was this translation helpful? Give feedback.
All reactions