Documentation ¶
Overview ¶
Package fetch provides logic to fetch URLs to monitor from UptimeRobot.
Index ¶
Constants ¶
const ( UptimeRobotAPIURL = "https://api.uptimerobot.com/v2/getMonitors" Interval = 1 * time.Second Timeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func Fetch ¶
Fetching the URLs to be monitored from UptimeRobot is easy; finding the best way to add them to the map of monitors has been difficult. Keep in mind that UptimeRobot API enforces a constraint: you can only fetch 50 monitors per request, not more.
Initialy I tried fetching a batch of URLs, then sending each URL one by one to the `found` channel (i.e. `chan string`). This worked fine until the map of monitors was large enough that polling all of them took longer than a poll tick (default 1m). At that point, only monitor could be added to the map during each poll cycle.
Next I tried changing `found` to `chan[] string`, and sending each batch of 50 (or less for the final batch). This worked better, but was still subject to the same consequence that only batch could be added per poll cycle.
So now I'm fetching *all* the URLs to be monitored (w/ as many requests as necessary), and sending them to the `found` channel in one (very) large batch.
Types ¶
type GetMonitorsResponse ¶
type GetMonitorsResponse struct { Pagination Pagination Monitors []Monitor }