Skip to content
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

Can Jobs be used with the new async system in vapor 3 #41

Open
abbasmousavi opened this issue Mar 29, 2018 · 4 comments
Open

Can Jobs be used with the new async system in vapor 3 #41

abbasmousavi opened this issue Mar 29, 2018 · 4 comments

Comments

@abbasmousavi
Copy link

@BrettRToomey, Can Jobs be used with the new async system in vapor 3?

@nevinjethmalani
Copy link

Would love to know how this would work in vapor 3 or if there is something similar for vapor 3. Do you know if you will update this for vapor 3? If I want to repeat a task within my vapor app every 10 seconds, is this the correct package/framework to use?

@Mordil
Copy link

Mordil commented Jun 13, 2018

@nevinjethmalani With NIO, you can schedule tasks on an EventLoop using scheduleTask(in:_:)

@nevinjethmalani
Copy link

@Mordil can you tell me how I would do that? I am new to vapor and don't even know where I would start putting code for something like this.

@Mordil
Copy link

Mordil commented Jun 13, 2018

@nevinjethmalani In your boot(_:) method (using the default structure defined in the Application docs), you can use the eventLoop property on the Application passed to the method to schedule the task as I described before.

You can recursively schedule the same task again as the final thing done in the task you schedule, so that it repeats indefinitely for the app's lifetime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants