Documentation
¶
Overview ¶
Package gokit is the umbrella for the Go service kit. Each subpackage is independently importable. Subpackages:
- fibermap: YAML-declarative Fiber router
- errs: typed domain errors + HTTP mapping
- db: pgx pool + transactions + healthcheck
- db/sqb: opt-in squirrel wrapper over db
- auth: JWT + refresh + ready-to-mount middleware
- clients/httpc: outbound *http.Client with retry/timeout
- clients/apimap: declarative outbound HTTP via YAML
- clients/nats: typed JetStream wrapper (package natsclient)
The root gokit package itself has no exported symbols. Importing one subpackage does not pull the others.
See README.md for the per-package overview and dependency rules.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package audit is an append-only audit-log primitive.
|
Package audit is an append-only audit-log primitive. |
|
auditadmin
Package auditadmin is a small browser UI for the audit log: search by actor / action / outcome / time-range, paginate, export the filtered set as JSON for compliance review.
|
Package auditadmin is a small browser UI for the audit log: search by actor / action / outcome / time-range, paginate, export the filtered set as JSON for compliance review. |
|
auditfm
Package auditfm wires the audit package into fibermap handler registration: a single per-handler decorator emits the audit event AFTER the handler returns, derived from the spec (Action / Target / Subject / Metadata) the caller declared at registration time.
|
Package auditfm wires the audit package into fibermap handler registration: a single per-handler decorator emits the audit event AFTER the handler returns, derived from the spec (Action / Target / Subject / Metadata) the caller declared at registration time. |
|
auditmw
Package auditmw is a Fiber middleware that auto-emits audit events from each inbound HTTP request.
|
Package auditmw is a Fiber middleware that auto-emits audit events from each inbound HTTP request. |
|
auditpg
Package auditpg is the Postgres-backed audit.Store.
|
Package auditpg is the Postgres-backed audit.Store. |
|
Package auth provides a complete authentication bundle for fibermap services: asymmetrically-signed JWT access tokens (EdDSA / ES256), opaque rotation-aware refresh tokens with reuse detection, argon2id password hashing, the IssueTokens / IssueLogin / IssueRefresh / Logout / RevokeRefresh / RevokeFamily / RevokeAllForSubject primitives, and Bearer/RequireScope/RequireRole middleware.
|
Package auth provides a complete authentication bundle for fibermap services: asymmetrically-signed JWT access tokens (EdDSA / ES256), opaque rotation-aware refresh tokens with reuse detection, argon2id password hashing, the IssueTokens / IssueLogin / IssueRefresh / Logout / RevokeRefresh / RevokeFamily / RevokeAllForSubject primitives, and Bearer/RequireScope/RequireRole middleware. |
|
apikeypg
Package apikeypg implements auth.KeyStore on top of Postgres via the kit's db.Querier interface.
|
Package apikeypg implements auth.KeyStore on top of Postgres via the kit's db.Querier interface. |
|
authtest
Package authtest exposes test-only helpers for the auth package that production code MUST NOT depend on.
|
Package authtest exposes test-only helpers for the auth package that production code MUST NOT depend on. |
|
fibermount
Package fibermount wires auth.Auth[C]'s middleware factories into a *fibermap.Engine[T].
|
Package fibermount wires auth.Auth[C]'s middleware factories into a *fibermap.Engine[T]. |
|
internal/memstore
Package memstore is an in-process RefreshStore used by auth handler tests.
|
Package memstore is an in-process RefreshStore used by auth handler tests. |
|
internal/principalkey
Package principalkey exposes the unexported Locals key that auth middleware (Bearer, API-key, session-bridge) uses to store the Principal on each request, and that auth/From / auth/MustFrom read it back from.
|
Package principalkey exposes the unexported Locals key that auth middleware (Bearer, API-key, session-bridge) uses to store the Principal on each request, and that auth/From / auth/MustFrom read it back from. |
|
refreshpg
Package refreshpg implements auth.RefreshStore on top of Postgres via the kit's db.Querier interface.
|
Package refreshpg implements auth.RefreshStore on top of Postgres via the kit's db.Querier interface. |
|
refreshredis
Package refreshredis implements auth.RefreshStore on top of Redis.
|
Package refreshredis implements auth.RefreshStore on top of Redis. |
|
sessions
Package sessions adds server-side cookie sessions to the JWT-first auth package.
|
Package sessions adds server-side cookie sessions to the JWT-first auth package. |
|
sessionsredis
Package sessionsredis implements auth/sessions.SessionStore on top of Redis.
|
Package sessionsredis implements auth/sessions.SessionStore on top of Redis. |
|
Package batch is the kit's generic batched-handler dispatcher.
|
Package batch is the kit's generic batched-handler dispatcher. |
|
Package breaker is the kit's generic three-state circuit breaker.
|
Package breaker is the kit's generic three-state circuit breaker. |
|
Package bulkhead is the kit's generic concurrency-cap with bounded wait queue.
|
Package bulkhead is the kit's generic concurrency-cap with bounded wait queue. |
|
clients
|
|
|
apimap
Package apimap is the kit's declarative outbound HTTP layer.
|
Package apimap is the kit's declarative outbound HTTP layer. |
|
cache
Package cache is a typed Redis-backed read-through cache.
|
Package cache is a typed Redis-backed read-through cache. |
|
email
Package email is a pluggable transactional-email kit.
|
Package email is a pluggable transactional-email kit. |
|
httpc
Package httpc is the kit's outbound HTTP client builder.
|
Package httpc is the kit's outbound HTTP client builder. |
|
nats
Package natsclient is the kit's NATS / JetStream wrapper.
|
Package natsclient is the kit's NATS / JetStream wrapper. |
|
natsmap
Package natsmap is the declarative YAML layer for NATS subscribers and publishers, symmetric to clients/apimap.
|
Package natsmap is the declarative YAML layer for NATS subscribers and publishers, symmetric to clients/apimap. |
|
natsmap/natsgw
Package natsgw is a generic HTTP→NATS gateway middleware.
|
Package natsgw is a generic HTTP→NATS gateway middleware. |
|
ratelimit
Package ratelimit is a Redis-backed sliding-window rate limiter.
|
Package ratelimit is a Redis-backed sliding-window rate limiter. |
|
redis
Package redisclient is the kit's thin wrapper around github.com/redis/go-redis/v9.
|
Package redisclient is the kit's thin wrapper around github.com/redis/go-redis/v9. |
|
s3
Package s3client is the kit's thin AWS S3 wrapper.
|
Package s3client is the kit's thin AWS S3 wrapper. |
|
webhooks
Package webhooks implements outbound + inbound HTTP webhook infrastructure for the kit: typed Subscription / Delivery rows persisted by an implementation of SubscriptionStore + DeliveryStore, a Fanout that turns one domain event into N per-target deliveries, a Worker that drains pending deliveries with per-target retry and dead-letter, an outbound Signer producing Stripe-style HMAC signatures, and a Verifier interface (with two ready-made implementations in clients/webhooks/verifiers) for inbound payloads.
|
Package webhooks implements outbound + inbound HTTP webhook infrastructure for the kit: typed Subscription / Delivery rows persisted by an implementation of SubscriptionStore + DeliveryStore, a Fanout that turns one domain event into N per-target deliveries, a Worker that drains pending deliveries with per-target retry and dead-letter, an outbound Signer producing Stripe-style HMAC signatures, and a Verifier interface (with two ready-made implementations in clients/webhooks/verifiers) for inbound payloads. |
|
webhooks/verifiers
Package verifiers ships ready-made implementations of clients/webhooks.Verifier.
|
Package verifiers ships ready-made implementations of clients/webhooks.Verifier. |
|
cmd
|
|
|
fibermap
command
Command fibermap is a small CLI around the fibermap library.
|
Command fibermap is a small CLI around the fibermap library. |
|
kit
command
Command kit is the kit's operator CLI: migrations, auth key minting, outbox inspection.
|
Command kit is the kit's operator CLI: migrations, auth key minting, outbox inspection. |
|
Package cronmap is the kit's declarative cron scheduler — symmetric to fibermap (HTTP routes), clients/apimap (outbound calls), and clients/natsmap (NATS pub/sub).
|
Package cronmap is the kit's declarative cron scheduler — symmetric to fibermap (HTTP routes), clients/apimap (outbound calls), and clients/natsmap (NATS pub/sub). |
|
Package crypto is the kit's standard at-rest sealing primitive.
|
Package crypto is the kit's standard at-rest sealing primitive. |
|
Package db is the kit's pgx-based connection layer.
|
Package db is the kit's pgx-based connection layer. |
|
inbox
Package inbox is the consumer-side companion to db/outbox.
|
Package inbox is the consumer-side companion to db/outbox. |
|
inbox/inboxnats
Package inboxnats wires db/inbox onto clients/natsmap handlers.
|
Package inboxnats wires db/inbox onto clients/natsmap handlers. |
|
jobs
Package jobs is a Postgres-backed delayed-job queue.
|
Package jobs is a Postgres-backed delayed-job queue. |
|
lock
Package lock is the kit's Postgres advisory-lock primitive.
|
Package lock is the kit's Postgres advisory-lock primitive. |
|
migrate
Package migrate is the kit's zero-dependency Postgres migration runner.
|
Package migrate is the kit's zero-dependency Postgres migration runner. |
|
outbox
Package outbox implements the transactional-outbox pattern over Postgres: events are written to an `outbox` table inside the same transaction as the business state, then a background Worker dispatches them to the real bus (NATS / Kafka / SQS) with at-least-once semantics.
|
Package outbox implements the transactional-outbox pattern over Postgres: events are written to an `outbox` table inside the same transaction as the business state, then a background Worker dispatches them to the real bus (NATS / Kafka / SQS) with at-least-once semantics. |
|
outbox/outboxnats
Package outboxnats wires db/outbox onto clients/natsmap's natsmap.PublishRaw — turning the manual three-line closure
|
Package outboxnats wires db/outbox onto clients/natsmap's natsmap.PublishRaw — turning the manual three-line closure |
|
sqb
Package sqb is an opt-in squirrel query-builder wrapper preconfigured for Postgres ($N placeholders).
|
Package sqb is an opt-in squirrel query-builder wrapper preconfigured for Postgres ($N placeholders). |
|
testdb
Package testdb provides testing helpers that spin up Postgres containers via testcontainers-go and return ready-to-use *db.DB handles.
|
Package testdb provides testing helpers that spin up Postgres containers via testcontainers-go and return ready-to-use *db.DB handles. |
|
Package errs defines typed domain errors for the fibermap kit.
|
Package errs defines typed domain errors for the fibermap kit. |
|
errsval
Package errsval converts go-playground/validator errors into *errs.Error.
|
Package errsval converts go-playground/validator errors into *errs.Error. |
|
examples
|
|
|
inbox-outbox
command
Command inbox-outbox is a single-process demo of the kit's effectively-once event flow: producer commits a domain row + an outbox row inside one Tx; an outbox worker drains the table through natsmap to JetStream; a consumer wraps its handler with inboxnats so redelivery dedups against an inbox row committed atomically with the consumer's domain write.
|
Command inbox-outbox is a single-process demo of the kit's effectively-once event flow: producer commits a domain row + an outbox row inside one Tx; an outbox worker drains the table through natsmap to JetStream; a consumer wraps its handler with inboxnats so redelivery dedups against an inbox row committed atomically with the consumer's domain write. |
|
resilience
command
Command resilience is a single-process demo of the kit's three outbound-HTTP resilience features composed together: circuit breaker, concurrency bulkhead, and YAML-declarative apimap.
|
Command resilience is a single-process demo of the kit's three outbound-HTTP resilience features composed together: circuit breaker, concurrency bulkhead, and YAML-declarative apimap. |
|
urlshort/shared/events
Package events is the SHARED event-payload contract between urlshort's three services (api / counter / enricher).
|
Package events is the SHARED event-payload contract between urlshort's three services (api / counter / enricher). |
|
urlshort/shared/migrations
Package migrations exports the urlshort schema migrations as an fs.FS.
|
Package migrations exports the urlshort schema migrations as an fs.FS. |
|
urlshort/urlshort-api
command
Command urlshort-api is the HTTP frontend of the urlshort sample.
|
Command urlshort-api is the HTTP frontend of the urlshort sample. |
|
urlshort/urlshort-api/internal/appctx
Package appctx defines the per-request AppCtx and a ContextBuilder that populates UserID from Bearer claims.
|
Package appctx defines the per-request AppCtx and a ContextBuilder that populates UserID from Bearer claims. |
|
urlshort/urlshort-api/internal/config
Package config defines urlshort-api's environment configuration.
|
Package config defines urlshort-api's environment configuration. |
|
urlshort/urlshort-api/internal/links
Package links holds the link domain — code generation, service, handlers.
|
Package links holds the link domain — code generation, service, handlers. |
|
urlshort/urlshort-api/internal/publisher
Package publisher is api-side wiring for the LinkVisited HTTP publish.
|
Package publisher is api-side wiring for the LinkVisited HTTP publish. |
|
urlshort/urlshort-api/internal/users
Package users owns the user account model — registration, password hashing, and the credentials verifier consumed by gokit/auth's LoginHandler.
|
Package users owns the user account model — registration, password hashing, and the credentials verifier consumed by gokit/auth's LoginHandler. |
|
urlshort/urlshort-counter
command
Command urlshort-counter is the batched visit-counter worker.
|
Command urlshort-counter is the batched visit-counter worker. |
|
urlshort/urlshort-counter/internal/counter
Package counter is the batched NATS-subscriber side of urlshort.
|
Package counter is the batched NATS-subscriber side of urlshort. |
|
urlshort/urlshort-enricher
command
Command urlshort-enricher is the metadata-fetcher worker.
|
Command urlshort-enricher is the metadata-fetcher worker. |
|
urlshort/urlshort-enricher/internal/enrich
Package enrich fetches title + description + image_url for a URL, using apimap for both the MicroLink lookup AND the open-client title fetch.
|
Package enrich fetches title + description + image_url for a URL, using apimap for both the MicroLink lookup AND the open-client title fetch. |
|
urlshort/urlshort-enricher/internal/enricher
Package enricher is the NATS-subscriber side of urlshort's metadata fetching.
|
Package enricher is the NATS-subscriber side of urlshort's metadata fetching. |
|
urlshort/urlshort-publisher
command
Command urlshort-publisher is the HTTP→NATS gateway + outbox drainer of urlshort.
|
Command urlshort-publisher is the HTTP→NATS gateway + outbox drainer of urlshort. |
|
Package fibermap loads YAML-described HTTP route trees and middleware chains into a Fiber router.
|
Package fibermap loads YAML-described HTTP route trees and middleware chains into a Fiber router. |
|
bind
Package bind provides typed request parse + validation helpers for fibermap (or any Fiber) handlers.
|
Package bind provides typed request parse + validation helpers for fibermap (or any Fiber) handlers. |
|
dev
Package dev wires the kit's dev-only DX tooling — HTML error pages with stack traces, route/config inspectors.
|
Package dev wires the kit's dev-only DX tooling — HTML error pages with stack traces, route/config inspectors. |
|
factory
Package factory ships ready-made middleware factories and adapters for fibermap.Engine.
|
Package factory ships ready-made middleware factories and adapters for fibermap.Engine. |
|
fibermaptest
Package fibermaptest provides assertion helpers for fibermap engines.
|
Package fibermaptest provides assertion helpers for fibermap engines. |
|
openapi
Package openapi generates OpenAPI 3.0 specifications from a fibermap fibermap.Engine.
|
Package openapi generates OpenAPI 3.0 specifications from a fibermap fibermap.Engine. |
|
sse
Package sse adds Server-Sent Events handlers to fibermap.
|
Package sse adds Server-Sent Events handlers to fibermap. |
|
uploadguard
Package uploadguard is a Fiber middleware that validates an inbound multipart-form file field BEFORE the handler sees it.
|
Package uploadguard is a Fiber middleware that validates an inbound multipart-form file field BEFORE the handler sees it. |
|
webhookguard
Package webhookguard ships a fiber middleware that verifies the signature of an inbound webhook payload against a clients/webhooks.Verifier.
|
Package webhookguard ships a fiber middleware that verifies the signature of an inbound webhook payload against a clients/webhooks.Verifier. |
|
ws
Package ws adds WebSocket handlers to fibermap on top of github.com/gofiber/websocket/v2.
|
Package ws adds WebSocket handlers to fibermap on top of github.com/gofiber/websocket/v2. |
|
wsnats
Package wsnats bridges browser WebSocket clients to NATS pub/sub.
|
Package wsnats bridges browser WebSocket clients to NATS pub/sub. |
|
Package ids is the kit's standard prefixed-ULID utility.
|
Package ids is the kit's standard prefixed-ULID utility. |
|
Package otelkit is the kit's thin OpenTelemetry tracing bootstrap.
|
Package otelkit is the kit's thin OpenTelemetry tracing bootstrap. |
|
Package reqctx carries the per-request identifier (X-Request-ID) through context.Context for cross-package propagation.
|
Package reqctx carries the per-request identifier (X-Request-ID) through context.Context for cross-package propagation. |
|
Package runbook is a runtime kill-switch primitive.
|
Package runbook is a runtime kill-switch primitive. |
|
Package schemas bundles the JSON Schema (draft-07) documents for every kit YAML config.
|
Package schemas bundles the JSON Schema (draft-07) documents for every kit YAML config. |
|
Package sentrykit is the kit's Sentry error-tracking bootstrap.
|
Package sentrykit is the kit's Sentry error-tracking bootstrap. |
|
Package service bundles every gokit subpackage into a single runtime.
|
Package service bundles every gokit subpackage into a single runtime. |
Click to show internal directories.
Click to hide internal directories.