Code and resources for a talk about Continuous Deployment for Gophercon AU
This is a small monorepo with a naive implementation of some HTTP APIs, and some build tooling.
For the purposes of the talk, there are also 3 Pull Requests open for discussion.
The jafflr is an imaginary machine which assembles and cooks toasted sandwiches.
It attaches onto a chilly bin ('Chilly bin' is NZ English parlance - aka Esky, in Australian).
There are 2 services, jafflr
and the chillybin
. Crucially, jafflr
depends on chillybin
.
Some of these endpoints use the wrong verb (GET instead of POST) - this has been left as "change needed":
- chillybin:
-
/pick?name=cheese&quantity=1
- pick stock from chillybin -
/
- show current stock -
/restock
- restock -
/health
- health check
- jafflr:
-
/toastie?i=cheese&i=vegemite
- make a toastie
- this invokes chillybin
-
/
retrieves status (toasting/available) -
/health
- health check
- Table-driven integration tests; fixtures, assertions, chaining together calls:
- Using httptest - example provided
- Managing database definitions with ‘migrations’:
- go-migrate. See chillybin
- With mongodb this can be as simple as "EnsureIndex()":w
- Bundling resources with your app (Docker or go-bindata):
- docker in this case
- Mitigating risk of changes:
- Feature Flags implemented via ENV or db
- 3 steps:
- Release something cross-compatible.
- Switch client over to the new API
- Delete old endpoint (for 3rd parties this gets more complicated)
- 3 steps:
- Versioning your APIs
- Could be a path
/v2/
- Could be version headers
- GraphQL supports
deprecated fields
- gRPC, Twirp [Protocol Buffers] support deprecations and field renaming
- Could be a path
- Zero-downtime deploys:
- HTTP - graceful restart. See jafflr
- healthchecks
- Metrics and alerting
- Tooling for your build system:
- Containerising build steps
- Deployment and confirmation (ECS/K8S)
-
go list -deps
for granular version checking. See last_commit.sh