A simple .env file has been provided.
docker compose up --build
Check all is good through Grafana at http://localhost:3000
with user-password both admin
.
If you restart the container, producer will fail because it will try to create tasks in the database that already exist from the previous run. So, use -v
flag to remove the volume of the db before relaunching:
docker compose down -v
go test --cover -v ./...
Most tests mock the db, but some need a real db instance. Those will fail.
Simply run:
docker compose -f docker-compose-test.yaml up -d --build
Now, you have a database instance. You just need to export the DB_URL to your terminal session:
export DB_URL=postgres://user:password@localhost:5432/golang_db_test
Now all tests should pass with go test --cover -v ./...
- Better tests, more tests.
- Share a bit more code between the services
- Rethink extendability into design
- Implement graceful shutdown of channels and contexts
- Make db operations transactional (pretty straightforward since DBTX interface supports it out-of-the-box)