Documentation
¶
Overview ¶
Package kit is the root of a module of small packages for Go services: build information, secrets from files, HTTP serving and health checks, JSON errors, retries, logging, metrics, PostgreSQL and migrations, password hashing and an attempt limiter, MQTT publishing with Home Assistant discovery, the client of the Herald notification service, and the summary an application gives a cockpit page. It holds no code of its own: import the package you need, such as kit/buildinfo or kit/httpserver.
The packages are split by weight. The ones a small service needs depend on the standard library only; PostgreSQL, Prometheus, zerolog and the command line library each stay behind the package that names them. weight_test.go keeps it that way.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package buildinfo carries the version stamped into a binary at build time.
|
Package buildinfo carries the version stamped into a binary at build time. |
|
Package cockpit serves an application's tile for a cockpit page that shows every application at a glance: GET /api/v1/cockpit with a bearer key, answering a small summary in Ukrainian and English.
|
Package cockpit serves an application's tile for a cockpit page that shows every application at a glance: GET /api/v1/cockpit with a bearer key, answering a small summary in Ukrainian and English. |
|
Package dbmigrate runs a service's SQL migrations with golang-migrate, read from a file system the binary embeds, so an image carries its own schema.
|
Package dbmigrate runs a service's SQL migrations with golang-migrate, read from a file system the binary embeds, so an image carries its own schema. |
|
Package dbpg opens the PostgreSQL connection pool of a service: parse the DSN, connect, and prove with a ping that the database answers before anything else starts.
|
Package dbpg opens the PostgreSQL connection pool of a service: parse the DSN, connect, and prove with a ping that the database answers before anything else starts. |
|
Package hamqtt builds Home Assistant MQTT discovery messages: the retained config a service publishes so that Home Assistant creates its entities, under <discovery prefix>/<component>/<node id>/<object id>/config.
|
Package hamqtt builds Home Assistant MQTT discovery messages: the retained config a service publishes so that Home Assistant creates its entities, under <discovery prefix>/<component>/<node id>/<object id>/config. |
|
Package healthcheck is the probe behind a service's `healthcheck` subcommand: the container asks its own HTTP endpoint whether it is ready, so the image needs no curl or wget.
|
Package healthcheck is the probe behind a service's `healthcheck` subcommand: the container asks its own HTTP endpoint whether it is ready, so the image needs no curl or wget. |
|
healthcheckcli
Package healthcheckcli wraps the healthcheck probe as an urfave/cli v3 subcommand.
|
Package healthcheckcli wraps the healthcheck probe as an urfave/cli v3 subcommand. |
|
Package herald is the client a producer uses to hand its notifications to Herald, the notification service.
|
Package herald is the client a producer uses to hand its notifications to Herald, the notification service. |
|
Package httpserver holds what every service repeats around net/http: a server with all four timeouts set, a run loop that shuts down gracefully, and the liveness and readiness handlers.
|
Package httpserver holds what every service repeats around net/http: a server with all four timeouts set, a run loop that shuts down gracefully, and the liveness and readiness handlers. |
|
Package jsonhttp writes JSON responses and the error envelope the web clients parse:
|
Package jsonhttp writes JSON responses and the error envelope the web clients parse: |
|
Package logx builds the one root logger of a service.
|
Package logx builds the one root logger of a service. |
|
Package mcpx serves an application's tools to MCP clients over the Model Context Protocol: one endpoint at /mcp, Streamable HTTP without sessions, behind a bearer key.
|
Package mcpx serves an application's tools to MCP clients over the Model Context Protocol: one endpoint at /mcp, Streamable HTTP without sessions, behind a bearer key. |
|
mcpxtest
Package mcpxtest helps an application test its MCP tools: an in-memory client session, tool calls read as text, and a check that no output carries a secret.
|
Package mcpxtest helps an application test its MCP tools: an in-memory client session, tool calls read as text, and a check that no output carries a secret. |
|
Package mqttx is an MQTT client for services that publish to a broker, typically for Home Assistant: it keeps the connection up, marks the service available through a retained status topic with a last will, and replays what the service publishes when the connection comes back or when Home Assistant restarts.
|
Package mqttx is an MQTT client for services that publish to a broker, typically for Home Assistant: it keeps the connection up, marks the service available through a retained status topic with a last will, and replays what the service publishes when the connection comes back or when Home Assistant restarts. |
|
Package promx sets up Prometheus for a service: a registry of its own, the /metrics handler and a build-info gauge.
|
Package promx sets up Prometheus for a service: a registry of its own, the /metrics handler and a build-info gauge. |
|
Package retry holds the small pieces every retry loop is built from: the next backoff delay, a random spread on top of it, a wait that ends with the context, and the Retry-After header.
|
Package retry holds the small pieces every retry loop is built from: the next backoff delay, a random spread on top of it, a wait that ends with the context, and the Retry-After header. |
|
Package secret resolves a secret that is configured either as a value or as a file holding it, the `X` and `X_FILE` pair every service repeats.
|
Package secret resolves a secret that is configured either as a value or as a file holding it, the `X` and `X_FILE` pair every service repeats. |
|
Package testpg gives an integration test a real PostgreSQL to run against: a fresh schema per test in a disposable database, dropped when the test ends.
|
Package testpg gives an integration test a real PostgreSQL to run against: a fresh schema per test in a disposable database, dropped when the test ends. |
|
Package webauth holds what a web service needs to let people and programs prove who they are: password hashes (argon2id), random tokens of which only a digest is stored, and a limiter for the endpoints that accept guessable secrets, and authenticator app TOTP.
|
Package webauth holds what a web service needs to let people and programs prove who they are: password hashes (argon2id), random tokens of which only a digest is stored, and a limiter for the endpoints that accept guessable secrets, and authenticator app TOTP. |
|
oidcsso
Package oidcsso verifies external OpenID Connect identities for local sign-in.
|
Package oidcsso verifies external OpenID Connect identities for local sign-in. |