sandbox

module
v0.4.44 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT

README

sandbox

Documentation License GitHub tag (latest by date) Build Status

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/secret
Package secret provides helpers for secret configuration values, such as passwords or private keys.
Package secret provides helpers for secret configuration values, such as passwords or private keys.
drivers/config/split
Package split provides unmarshalers for Koanf config structs to convert strings to string slices using a particular delimiter.
Package split provides unmarshalers for Koanf config structs to convert strings to string slices using a particular delimiter.
drivers/pgsql
Package pgsql provides a PostgreSQL implementation of sql.DB.
Package pgsql provides a PostgreSQL implementation of sql.DB.
drivers/rpcserver/coverage
Package coverage exposes a HTTP handler to execute runtime/coverage functions on-demand without having to terminate the process.
Package coverage exposes a HTTP handler to execute runtime/coverage functions on-demand without having to terminate the process.
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.
pkg
Package pkg contains mature and re-usable packages that could be used in other projects.
Package pkg contains mature and re-usable packages that could be used in other projects.
exit
Package exit provides constants for process exit codes.
Package exit provides constants for process exit codes.
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.
slogt
Package slogt integrates testing and log/slog together.
Package slogt integrates testing and log/slog together.
slogx
Package slogx provides additional helpers for log/slog consumers.
Package slogx provides additional helpers for log/slog consumers.
timex
Package timex provides time functions via a struct.
Package timex provides time functions via a struct.
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