-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to process/retrieve the result of a task and how to pass a non serializable context to the task? #147
Comments
Seems doable to have a global pool, e.g. https://stackoverflow.com/a/63153898 Still interested in your take on this ;) |
Hello, |
More specifically I would want the task to output a stream of data |
It would be nice if we could pass a MPSC sender instance through the task's run method. It would allow data streaming between the consumer and the senders (workers). Let me know if there's already a way to do that, I can't find a way to pass a sender instance to the tasks. |
There is no current way to pass non-serializable object to a task. One work-around you can do is to make the Task fields to be database pool, or connetion url which are both serializable and the work will store in the database the stuff you want. After that, do another task that will fetch from database every cetain amount of time. The main problem that this
can not be implemented yet, I think (I am not sure because Rust has been changing since i have implemented it). The reason is that async traits do not allow generics, at least at the moment we have done the implementation. |
I have been reasearching about this and I think since Rust 1.75 this change could be possible. As soon as Sqlite PR and Mysql closes #141 , I will open a experimental PR exploring this. |
not a good choice in global. |
Hello,
Thank you for your work. :)
I am wondering the following things:
run
function?(Feel free to tell me if you would like me to split this into multiple issues.)
E.g. I would like to store the result inside the database or transmit the result to another service (in-memory) without doing an API call to
localhost
if I am running the workers within an API.And I don't want to build the client/db pool for every task from environment variables.
run
signature isResult<(), FangError>
thus I could not make my ownAsyncWorker<AQueue>
orAsyncWorkerPool<AQueue>
that would handle the result of a task.And since a task should be serializable, I cannot provide to it clients (database or otherwise) that I would not want serializable but that I would want to access in the
run
function.I am thinking that the only way would be to attempt to access a global reference to a singleton or something alike, e.g.:
Though I am not sure that the compiler would allow me to do so.
fang
and you don't need this?Maybe it is part or could be part of the following discussion #101 ?
I understand that this could/would considerably complicate the implementation, but no harm in asking 😇.
The text was updated successfully, but these errors were encountered: