How can I get the task ID of the current job inside send_email? #546
-
|
How can I get the task ID of the current job inside send_email? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
You should be able to use dependency injection offered by FromRequest This example shows how to do it: |
Beta Was this translation helpful? Give feedback.
-
|
Thank you so much for your patient replies. I want to ask about the difference between the result.task_id (the ID returned when submitting the job) and the internal task_id: TaskId(UID) in the framework. If I want to retrieve the result.task_id generated in this line: let result = storage.redis_storage.push(job).await.map_err(ApiError::from)?; how can I access it within the simple_job function? Are these two IDs completely separate, or is there a way to map them? |
Beta Was this translation helpful? Give feedback.
You should be able to use dependency injection offered by FromRequest
This example shows how to do it:
https://github.com/geofmureithi/apalis/blob/45a4cbee6be611054a7be0a31c6e849dbc2549f0/examples/fn-args/src/main.rs#L21-L34