This repo is for the loader component of WiperCheck. For the WiperCheck service see here.
The loader is an optional component for caching forecasted weather data to improve performance. It scans over a configured coordinate grid, retrieving and caching hourly weather data for the following 48 hours.
The loader runs as a continuous job, populating over the specified area in a loop. Once retrieved from OpenWeather, the forecasted weather data is cached using redis' geospacial functionality. This feature allows a user to pass in a coordinate, to which redis will return the coordinates in the database closest to it. By setting the key value of the weather data saved in redis to the unix time of the weather information and the name to the weather data, the service can find the closest cached weather data to a given coordinate at a given time in a simple query.
For deploying to AWS, see wipercheck-infra. The below steps are for local development.
- Go 1.17 or later
- A redis cluster for caching the forecasted weather data
-
Clone the repo
git clone https://github.com/evanhutnik/wipercheck-loader.git
-
Get an API key for OpenWeather
-
Add file named
.envto root of project with the following fields:loader_start_lat=47.875 loader_start_lon=83.923 loader_stepdistance=10 loader_duration=60 openweather_apikey={api key} openweather_baseurl=https://api.openweathermap.org/data/2.5/onecall redis_address={redis url}loader_start_lat: The latitude of the cache start point.loader_start_lon: The longitude of the cache start point.loader_stepdistance: The distance, in kilometres, between each cached location. The points are cached in a grid shape, so a value of 10 would result in locations being cached every 10km east-west as well as north-south.loader_duration: The amount of time, in seconds, it will take to complete an entire cache cycle. Ex. a value of 3600 seconds would result in a 60x60 grid east/south of the starting point. -
Build the loader
go build -o ./bin/wipercheck-loader ./cmd/loader/main.go
-
Run the executable
./bin/wipercheck-loader


