Local development and testing
- How to run and test a generated service with its own Makefile
- How to add a second service to the same project
- What's shared between services, and what isn't yet
Build, run, test
From the project root, with services/articles/ created (Creating
services):
make env-up # generated project: Mongo :27017
make build SERVICE=articles
make run SERVICE=articles # :8080, auth disabled
curl -X POST localhost:8080/articles -H 'Content-Type: application/json' \
-d '{"name":"hello"}'
curl localhost:8080/articles/<id-from-the-response>
make test
make test runs go test ./..., so it picks up every service's tests
in one pass — resource_test.go's testkit.Service call gives each
test its own throwaway Mongo database, same as everywhere else in
this framework (see Testing).
Adding a second service
hyrule service create authors
make build SERVICE=authors
make run SERVICE=authors GO_PORT=8081
Each service is its own binary (go build -o .local/<name> ./services/<name>), so two can run side by side on different ports —
GO_PORT picks the port make run listens on. There's no process
manager or docker-compose entry generated per service; for local
development, running the ones you're working on in separate terminals
is enough. (make env-up's docker-compose.yml is shared
infrastructure — Mongo — not a per-service thing to add to.)
What's shared, what isn't
Today, services in the same project share:
- The
go.mod(one module, onego.sum) and the local Mongo fromdocker-compose.yml. - The
Makefile's pattern (SERVICE=-parametrized targets).
They do not share a coordinated multi-service dev command (there's
no hyrule dev that starts every service at once — see
ADR-0004)
or cross-service relations out of the box — wiring one service's
resource to another's (an author_id field, say) is written the same
way Relations and Hooks shows for
blog-apis's posts-api → authors-api/categories-api, by hand.
make build/make run/make test SERVICE=<name>work exactly like this repository's own Makefile — nothing new to learn.make testcovers every service in one pass; running services locally is onemake runper service, in its own terminal.- There's no multi-service
devcommand yet — see the roadmap.
Mongo and Postgres services
The generated project template remains Mongo-specific; its own compose ports
may differ from the Hyrule repository compose. For an existing Go service,
the backend guide shows complete Mongo and Postgres
registration, connection variables, schema setup, tests and opt-ins. Postgres
resources run through app.Main too; a different URI alone does not convert a
Mongo/YAML service. The HA lab is manual/local and separate from make env-up.