Ugly-scheduler is just a simple schedule service. It uses Twirp-based API which provides benefits from Google's protobuf (code generation) and REST JSON API (simple request construction).
- Go 1.13
- PostgreSQL 9.5 or greater
Service configured using command-line options and environment variables.
--addr
, addr:port to run service on (default::8001
)
DB_HOST
, DB host (default:localhost
)DB_PORT
, DB port (default:5432
)DB_NAME
, DB name (default:ugly-scheduler
)DB_USER
, DB user (default:postgres
)DB_PASSWORD
, DB password (default not set)
- clone this repository to
$GOPATH/src/github.com/renskiy
directory - install or update
protoc-gen-go
package
go mod download
createdb ugly-scheduler
go get -u github.com/rubenv/sql-migrate/...
go run ./cmd/sql-migrate-config | sql-migrate up -config /dev/stdin -env default
Create special DB for tests, set DB_NAME_TEST
* env var and run following command:
go test -v -count 1 -p 1 ./...
* default value for DB_NAME_TEST
is ugly-scheduler-test
go run ./cmd/server --addr :8001
go run ./cmd/server --addr :8002
With default settings one can do requests like following:
curl -X POST "http://localhost:8001/twirp/scheduler.Scheduler/Schedule" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"delay\": \"1\", \"message\": \"Hello world\"}"