This episode is for members only

Sign up to access "Build An Uptime Monitor with Inertia" right now.

Get started
Already a member? Sign in to continue
Playing
20. Determining endpoints to check

Episodes

0%
Your progress
  • Total: 4h 59m
  • Played: 0m
  • Remaining: 4h 59m
Join or sign in to track your progress

Transcript

00:00
we're now on to the fun part where we actually get to start performing checks now to do this we're going to have a central console command which will use our next check date or and time and find out all of the endpoints in the app which need to be checked
00:18
so let's head over and just start to create this out we're not going to do anything with this we're just going to go ahead and make sure that we're getting these records right so we're going to go ahead and make a command here called perform checks and let's go ahead and open that up that's under console and commands and let's just fill out some of the information in here first of all so
00:37
let's just say checks perform we're going to need to reference this in our schedule because obviously we don't want to have to manually run this ourselves it's going to be scheduled on a very short schedule and let's go ahead and just give this a description so let's just say perform endpoint checks okay so to run this at the moment it just goes ahead and returns a success code
00:58
which is absolutely fine we are just going to use artisan so we're going to go ahead and say checks and perform there we go it doesn't do anything at the moment so to grab a list of the endpoints which need to be checked or are overdue to be checked it's actually pretty straightforward so let's go ahead and we don't actually need to assign this but let's go ahead and assign it now
01:21
just so we can grab a count from this we're of course going to use the endpoint model and we really just need a very simple where for next check and we just want to check where this is less than or equal to the current date and time so let's leave it at that for now and let's just go ahead and grab the count from this and just die dump on the count so i'm going to go ahead
01:46
and run this and sure enough we get two if we head over to the database here you can see that the next check here is already in the past if i were to go ahead and update this one to now and then go ahead and modify this to be just a few minutes or a couple of minutes into the future we would expect when we run this command again to only see one because we haven't got to the point
02:10
yet where this is less than the current date so really that is everything we need to do to grab the end points that we want to check now what we're not going to do is go ahead and start to iterate through these and just start to perform http checks we need to think a bit more deeply about this because we really want to put these into a queue to be run on a queue so we don't
02:34
slow everything down so what we're eventually going to get to the point where we do is because we get a collection back from here we can just say each and then go ahead and do something inside of here and that is going to be dispatching a job which we can put on our queue so why don't we go over to the next episode fill in this job and update the next check within that endpoint
44 episodes4 hrs 59 mins

Overview

Ready to dive into Inertia? Let's build a real-world app with Laravel, Inertia and Vue! If you're already working with Inertia, you'll pick up some tips and techniques for future projects.

This uptime monitor allows you to create and switch between sites, then add endpoints to monitor with frequency intervals. Using the power of scheduling and queues, it'll automatically alert the email addresses you've added via the UI when an endpoint goes down.

In this course, you'll learn to:

  • Build a real app from scratch with Inertia
  • Work with Laravel queues
  • Perform actions on models at user-defined intervals
  • Work with sub-minute schedules in Laravel
  • Send out channel notifications with Laravel
  • Use API resources to simplify Inertia data
  • Organise apps with events and observers
  • Create modals in Vue
  • Perform inline editing with Inertia forms
Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Episode discussion

No comments, yet. Be the first!