In this episode, we dive into creating a job to actually perform our endpoint check. We start by setting up a new job class called PerformEndpointCheck
inside the jobs folder. To keep things simple and test it out, we skip queueing for now and focus on making sure the job logic works as expected.
We set up the job so it takes an endpoint as a parameter in the constructor, which allows us to handle different endpoints dynamically. Then, inside the job's handler, we add the essential logic: updating the next_check
column on the endpoint. This is important because we definitely don't want to keep checking endpoints every second (which is what would happen if we skipped this!), so we explicitly add the endpoint's frequency to the current timestamp and update the value. That way, the next check will be correctly scheduled.
Finally, we test out dispatching the job and see how the job properly updates the next check time for overdue endpoints. This gives us a great foundation, and in the next episode, we'll move on to actually making HTTP requests within our job.