Skip to content

Instantly share code, notes, and snippets.

View jahredhope's full-sized avatar

Jahred Hope jahredhope

View GitHub Profile
@divan
divan / main.go
Created March 21, 2017 15:01
Golang database/sql+http example (postgres)
// Run PostgreSQL server:
// docker run -e POSTGRES_PASSWORD="" -p 5432:5432 postgres
// Monitor running processes:
// watch -n 1 'echo "select pid,query_start,state,query from pg_stat_activity;" | psql -h localhost -U postgres
//
// For all handlers, call to db takes 5 seconds,
//
// Three endpoints:
// - "/" - take 5 seconds
// - "/ctx" - take 1 seconds, due to 1 second cancellation policy