An application which periodically reads and stores gauge data for rivers via the United States Geological Survey Instantaneous Values Web Service.
The gauge data is served via a read only REST API.
The API is intended to be consumed by a front end application aimed at providing easy to read river information for paddlers.
/api/rivers
- Returns a list of all tracked rivers
/api/rivers/:id
- Returns a single river
/api/rivers/:id/gauges
- Returns a list of gauges for a single river
/api/gauges
- Returns a list of all tracked gauges
/api/gauges/:id
- Returns a single gauge
/api/gauges/:id/metrics
- Returns metrics for a single gauge
A local instance can be created in docker using the docker compose in the root directory of the repo.
This will spin up an instance running the latest master.
docker-compose up
The database can be seeded by running the seeder
program in the ort_api
container passing the directory of the seed files as a parameter.
docker exec -it ort_api /bin/bash
./seeder rivers/
By default gauges are read, and their values stored every 15 minutes. TODO make this configurable with an env var.
The project makes use of a PostgreSQL 12 database.
Migrations are handled via golang-migrate
migrate create -dir=db/migrations/ -ext=.sql <migration_name>
Migrations run automatically when starting the main Go API.
However, they can also be run manually if need be.
migrate -path=db/migrations/ -database <postgres_connection_string> up
Tests are written using test suites
go test ./... -cover