-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Background task #74
Comments
We currently support the cron tasks running in the background. It seems that you need a single immediately executed task. We may add this feature in the next release. |
@akelyasir Does the tokio::task::spawn work in your case? |
Hi @photino I would also like to make the background job repeat more than once in case it fails, and I will also record the status and results of the operations that create a model for background jobs. I would also like to make the background job repeat more than once in case it fails, and I will also record the status and results of the operations that create a model for background jobs. I found https://github.com/geofmureithi-zz/apalis for Actix. It can be referenced or integrated. But I couldn't find exactly where to start. |
Hi @photino For example, if an function that we will call in controller we have created will take a long time, to run this function in the background and finish the controller operation as complate. `
` How is it appropriate to carry out such an operation. I thought of adding it to the redis or database as a task and running the functions of the incomplate task with cron, but I couldn't figüre out how to call the functions. |
@akelyasir Another possile solution is using a queue. You can create a global channel to receive the data (such as in the form of CloudEvent) from the controller and then run the process logic asynchronously. |
@akelyasir I think what you need is an event-driven approach. You may also refer to https://news.ycombinator.com/item?id=38349716 |
This approach is also OK. You can save the necessary data to the database, such as the id, name, email address and status to be sent an email to. In the cron job, you first filter the users by the status and then run the process logic asynchronously. |
@photino Thank you for your help. I will investigate what you have said. |
@photino Can you give an example about Cloudevent? |
CloudEvent is a vendor-neutral specification for defining the format of event data. In zino, you can define an event such as let mut event = CloudEvent::new(id, source, event_type);
event.set_data(json!({
"sender": "alice",
"receiver": "bob",
"message": "test",
}); In your task queue, you can subscribe the events with a specified |
Hi @photino
How can we add background jobs for the queries made. In order not to keep any request waiting. For example, we have sent an e-mail and to complete the process by adding it to the background jobs without waiting for it to arrive.
The text was updated successfully, but these errors were encountered: