sandbox

module
v0.3.85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: MIT

README

sandbox

A toy Go microservice intended for use as reference material.

Features

  • Uses a directory structure (mostly) adherent to clean architecture.
  • API provided by ConnectRPC, validation using protovalidate, Buf generated, reflection enabled.
  • Database provided by PostgreSQL, UUIDv7 for primary keys, Jet for SQL query building.
  • OpenTelemetry Metrics and Tracing, standardised metrics and attributes whenever possible.
  • Logging using log/slog.
  • Runtime configuration via Koanf.
  • Grafana (with version-controlled dashboards), VictoriaMetrics and Jaeger for observability.
  • CI using GitHub actions, with Zizmor for linting.
  • Vulnerability and License scanning using Trivy.
  • Secret scanning using Gitleaks.
  • Dependency updates from Dependabot.
  • Packaged using Docker containers, developed with Docker Compose.

Sanity tests

# ready: success
echo '{}' | grpc-client-cli -a localhost:5000 -s Health -m Check

# login
echo '{"id":"example","secret":"example"}' | grpc-client-cli -a localhost:5000 -s AuthnService -m Login

token=`echo '{"id":"example","secret":"example"}' | \
  grpc-client-cli -a localhost:5000 -s AuthnService -m Login | \
  jq -r '.access_token'`

# authenticate
echo "{\"token\":\"${token>}\"}" | grpc-client-cli -a localhost:5000 -s AuthnService -m Authenticate

# create: success
echo '{"resource":{"name":"example"}}' | \
	grpc-client-cli \
		-a localhost:5000 \
		-s ExampleService \
		-m CreateResource \
		-H "Authorization: Bearer $token"

# create: success (bulk)
for i in {1..100}; do
	echo "{\"resource\":{\"name\":\"example-$i\"}}" | \
		grpc-client-cli \
		-a localhost:5000 \
		-s ExampleService \
		-m CreateResource \
		-H "Authorization: Bearer $token"
done

# list: success
echo '{"limit": 100}' | \
	grpc-client-cli \
		-a localhost:5000 \
		-s ExampleService \
		-m ListResources \
		-H "Authorization: Bearer $token"

Directories

Path Synopsis
cmd
example-health command
example-rpc command
example-tui command
gen
internal
adapters
Package adapters provides application-specific logic.
Package adapters provides application-specific logic.
domain
Package domain contains the domain layer for the application.
Package domain contains the domain layer for the application.
domain/entities
Package entities contains the models for the application.
Package entities contains the models for the application.
domain/repositories
Package repositories package describes the implementation-agnostic interaction points with other parts of the business.
Package repositories package describes the implementation-agnostic interaction points with other parts of the business.
drivers
Package drivers provides code that is neither application or business specific.
Package drivers provides code that is neither application or business specific.
drivers/config
Package config provides support for loading configuration from various sources into a struct.
Package config provides support for loading configuration from various sources into a struct.
drivers/config/flagoptions
Package flagoptions implements config.Options using the standard library flag package.
Package flagoptions implements config.Options using the standard library flag package.
drivers/config/providers/k8smount
Package k8smount contains a Koanf provider for loading configuration from Kubernetes volume mounts, i.e.
Package k8smount contains a Koanf provider for loading configuration from Kubernetes volume mounts, i.e.
drivers/config/splitter
Package splitter provides unmarshalers for Koanf config structs to convert strings to string slices using a particular delimiter.
Package splitter provides unmarshalers for Koanf config structs to convert strings to string slices using a particular delimiter.
drivers/exit
Package exit provides constants for process exit codes.
Package exit provides constants for process exit codes.
drivers/pgsql
Package pgsql provides a PostgreSQL implementation of sql.DB.
Package pgsql provides a PostgreSQL implementation of sql.DB.
...
drivers/rpcserver/rpcerrors
Package rpcerrors provides a small utility for creating ConnectRPC errors based on string messages instead of existing errors.
Package rpcerrors provides a small utility for creating ConnectRPC errors based on string messages instead of existing errors.
usecases
Package usecases contains the usecases layer for the application.
Package usecases contains the usecases layer for the application.
mocks
pkg
herd
Package herd provides support for running migrations against a PostgreSQL database.
Package herd provides support for running migrations against a PostgreSQL database.
otelt
Package otelt provides helpers for testing the results of OpenTelemetry metrics and traces.
Package otelt provides helpers for testing the results of OpenTelemetry metrics and traces.
tests
tools
coverage-report command
filter-coverage command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL