ozark-river-tracker

command module
v0.0.0-...-1582af6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

README

Overview

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.

Endpoints

/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

Running a Local Instance

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
Seeding the Database

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/
Reading Gauges

By default gauges are read, and their values stored every 15 minutes. TODO make this configurable with an env var.

Database

The project makes use of a PostgreSQL 12 database.

Migrations are handled via golang-migrate

Creating a New Migration
migrate create -dir=db/migrations/ -ext=.sql <migration_name>
Running Migrations

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

Tests are written using test suites

Running Tests
go test ./... -cover

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
db
pkg
tasks

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL