gokit

module
v0.3.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT

README

gokit

CI Go Reference

A modular Go toolkit for building production services. Config, logging, resilience, observability, dependency injection, and infrastructure adapters — so teams can focus on business logic instead of reinventing plumbing.

Status — pre-1.0. Public surface is semver-stable per module; breaking changes are documented in CHANGELOG.md. See docs/policy/SEMVER.md.

Latest release — v0.2.0. The next development line being prepared is v0.3.0-alpha.1, a prerelease for evaluation and integration testing; APIs may change before the stable v0.3.0.

Sibling projects. gokit (Go, this repo) · rskit (Rust) · pykit (Python). Public abstractions (AppError, Component, Provider, Stream, lifecycle hooks) are evaluated for parity across all three.

Browse by Domain

Modules are organized into domains for scoped development. See Module Index for the full breakdown.

Domain Focus Quick check
core Foundation types, config, logging make check-core
patterns Component, provider, DI, hooks make check-patterns
crosscutting Observability, resilience, security make check-crosscutting
composition Bootstrap, stream, DAG, workers make check-composition
transport Server, HTTP, gRPC, SSE make check-transport
auth Authentication, authorization make check-auth
data Database, cache, storage, messaging make check-data
ai LLM, inference, agents, tools make check-ai
media Light detection, metadata, image ops make check-media
infra Workload, CLI, dataset, benchmarks, testing make check-infra
devtools Git repository operations make check-devtools

CI still runs full-workspace validation; on pull requests the changes job also publishes an affected domain list from ./scripts/affected-domains.sh so later workflow steps can consume the same domain mapping developers use locally with make check-<domain>.

Highlights

  • Multi-module layout — light core (github.com/kbukum/gokit) + sub-modules (gokit/server, gokit/database, …) you opt into individually. No transitive heavy deps unless you ask.
  • Lifecycle-managed components — uniform Component interface (start / stop / health) and bootstrap.App orchestrator with graceful shutdown.
  • Production resilience — circuit breakers, retries with backoff + jitter, bulkheads, rate limiting, OpenTelemetry tracing & metrics.
  • Provider pattern — typed RequestResponse[I,O], Stream, Sink, and Duplex traits with composable middleware and sink combinators.
  • Per-module versioning — every module has its own matching tag, while normal releases are cut in lock-step for convenience. See docs/VERSIONING.md.
  • Sibling parity — APIs mirror rskit (Rust) and pykit (Python).

Install

# Core (lightweight, zero heavy deps)
go get github.com/kbukum/gokit@latest

# Add sub-modules à la carte
go get github.com/kbukum/gokit/server@latest
go get github.com/kbukum/gokit/database@latest

Requires Go 1.26+.

Quickstart

package main

import (
    "context"

    "github.com/kbukum/gokit/bootstrap"
    "github.com/kbukum/gokit/config"
)

type Config struct {
    config.ServiceConfig `mapstructure:",squash"`
}

func main() {
    cfg := &Config{ServiceConfig: config.ServiceConfig{Name: "my-service", Version: "1.0.0"}}

    app, err := bootstrap.NewApp(cfg)
    if err != nil {
        panic(err)
    }

    app.OnConfigure(func(ctx context.Context, app *bootstrap.App[*Config]) error {
        // wire routes, handlers, business logic — components are already started
        return nil
    })

    // Init → Start → Configure → Ready → wait for signal → Stop
    if err := app.Run(context.Background()); err != nil {
        app.Logger.Fatal("app failed", map[string]any{"error": err})
    }
}

More examples → docs/EXAMPLES.md. Full package list → docs/PACKAGES.md.

Documentation

Topic Link
All packages & sub-modules docs/PACKAGES.md
Usage examples docs/EXAMPLES.md
Architecture decisions docs/adr/
Versioning & releases docs/VERSIONING.md · docs/RELEASING.md
Semver & deprecation policy docs/policy/SEMVER.md · docs/policy/DEPRECATION.md
Cross-module integration INTEGRATION.md
Per-package API docs pkg.go.dev

Development

make check    # build + vet + test (all modules)
make test     # tests with -race across all modules
make lint     # golangci-lint
make tidy     # go mod tidy for core + sub-modules

Contributing

We welcome contributions. See CONTRIBUTING.md for setup, coding standards, and the PR process. By participating you agree to the Code of Conduct.

Other community docs: SECURITY.md · GOVERNANCE.md · MAINTAINERS.md

License

MIT — Copyright (c) 2024 kbukum

Directories

Path Synopsis
ai module
auth module
authz module
bench module
Package bootstrap orchestrates application lifecycle for gokit services.
Package bootstrap orchestrates application lifecycle for gokit services.
cache module
Package chain provides typed, sequential chain execution.
Package chain provides typed, sequential chain execution.
cli
Package cli is a parser-agnostic terminal-UX toolkit for building consistent command-line experiences across gokit services.
Package cli is a parser-agnostic terminal-UX toolkit for building consistent command-line experiences across gokit services.
live
Package live provides a bounded, multi-region live console for streaming several concurrent outputs as fixed-height tiles.
Package live provides a bounded, multi-region live console for streaming several concurrent outputs as fixed-height tiles.
progress
Package progress renders progress bars and spinners over an injected writer.
Package progress renders progress bars and spinners over an injected writer.
prompt
Package prompt provides interactive prompts for guided CLI flows.
Package prompt provides interactive prompts for guided CLI flows.
render
Package render is the structured, non-interactive terminal display layer of the CLI kit.
Package render is the structured, non-interactive terminal display layer of the CLI kit.
signal
Package signal maps interactive interrupts (Ctrl+C / SIGTERM) onto cooperative context.Context cancellation.
Package signal maps interactive interrupts (Ctrl+C / SIGTERM) onto cooperative context.Context cancellation.
theme
Package theme is the visual vocabulary shared by every CLI renderer: color and status glyphs.
Package theme is the visual vocabulary shared by every CLI renderer: color and status glyphs.
Package codec provides pluggable structured-text codecs over a shared value tree.
Package codec provides pluggable structured-text codecs over a shared value tree.
framing
Package framing provides bounded length-delimited framing for streaming codec values over a byte transport.
Package framing provides bounded length-delimited framing for streaming codec values over a byte transport.
value
Package value merges codec value trees with configurable array semantics.
Package value merges codec value trees with configurable array semantics.
Package component defines the core interfaces for lifecycle-managed infrastructure services in gokit.
Package component defines the core interfaces for lifecycle-managed infrastructure services in gokit.
Package config provides configuration loading and validation for gokit applications.
Package config provides configuration loading and validation for gokit applications.
connect module
testutil module
dag
Package dag provides a DAG (Directed Acyclic Graph) execution engine for orchestrating provider-based service calls in dependency order.
Package dag provides a DAG (Directed Acyclic Graph) execution engine for orchestrating provider-based service calls in dependency order.
cascade
Package cascade provides staged DAG-style execution where each stage can build provider-backed nodes, order them by metadata, and control stage/final-stage failure behavior.
Package cascade provides staged DAG-style execution where each stage can build provider-backed nodes, order them by metadata, and control stage/final-stage failure behavior.
status
Package status defines shared DAG execution status values for root DAG execution and DAG subpackages.
Package status defines shared DAG execution status values for root DAG execution and DAG subpackages.
database module
testutil module
Package di provides a small, type-keyed dependency injection container.
Package di provides a small, type-keyed dependency injection container.
discovery module
embedding module
Package encryption provides authenticated encryption utilities for sensitive data in gokit applications.
Package encryption provides authenticated encryption utilities for sensitive data in gokit applications.
Package errors provides unified error handling for Go services.
Package errors provides unified error handling for Go services.
fs
Package fs provides local filesystem primitives for safe paths, temporary files and directories, atomic writes, permissions, metadata, symlinks and hard links, bounded archive create/extract (tar.gz and zip), debounced change watching, and OS-standard application directories.
Package fs provides local filesystem primitives for safe paths, temporary files and directories, atomic writes, permissions, metadata, symlinks and hard links, bounded archive create/extract (tar.gz and zip), debounced change watching, and OS-standard application directories.
testutil
Package testutil provides filesystem test fixtures for gokit fs tests and downstream users.
Package testutil provides filesystem test fixtures for gokit fs tests and downstream users.
git module
grpc module
Package hook provides a lightweight, generic observe-only event system.
Package hook provides a lightweight, generic observe-only event system.
httpclient module
kafka module
llm module
providers module
Package logging provides structured logging for gokit applications using zerolog.
Package logging provides structured logging for gokit applications using zerolog.
messaging module
Package observability provides OpenTelemetry tracing and metrics integration for comprehensive service observability.
Package observability provides OpenTelemetry tracing and metrics integration for comprehensive service observability.
Package process provides subprocess execution with context cancellation, signal handling, and structured output capture.
Package process provides subprocess execution with context cancellation, signal handling, and structured output capture.
testutil
Package testutil provides process test fixtures for gokit process tests and downstream users.
Package testutil provides process test fixtures for gokit process tests and downstream users.
Package provider implements a generic provider framework using Go generics for swappable backends with runtime switching capabilities.
Package provider implements a generic provider framework using Go generics for swappable backends with runtime switching capabilities.
namedregistry
Package namedregistry provides a generic, name-keyed registry.
Package namedregistry provides a generic, name-keyed registry.
redis module
Package resilience provides patterns for building fault-tolerant systems.
Package resilience provides patterns for building fault-tolerant systems.
schema module
scripts
semver-max command
Command semver-max reads whitespace-separated semantic versions from stdin and prints the single SemVer-highest one, exiting non-zero if none are valid.
Command semver-max reads whitespace-separated semantic versions from stdin and prints the single SemVer-highest one, exiting non-zero if none are valid.
Package security provides shared security primitives for gokit modules.
Package security provides shared security primitives for gokit modules.
tlstest
Package tlstest generates throwaway TLS material for tests.
Package tlstest generates throwaway TLS material for tests.
server module
Package sse provides Server-Sent Events (SSE) support for real-time streaming.
Package sse provides Server-Sent Events (SSE) support for real-time streaming.
storage module
Package stream provides composable, pull-based data stream operators plus a bounded push fan-out source.
Package stream provides composable, pull-based data stream operators plus a bounded push fan-out source.
testutil module
tool module
Package util provides small, generic helpers shared across gokit — the scoped foundation owner for capabilities too small to deserve their own package, never a dumping ground.
Package util provides small, generic helpers shared across gokit — the scoped foundation owner for capabilities too small to deserve their own package, never a dumping ground.
Package validation provides input validation utilities for gokit handlers.
Package validation provides input validation utilities for gokit handlers.
vectorstore module
Package version provides immutable build metadata for gokit applications.
Package version provides immutable build metadata for gokit applications.
Package worker provides push-based task execution with real-time event streaming, worker pools, and supervision.
Package worker provides push-based task execution with real-time event streaming, worker pools, and supervision.
workload module

Jump to

Keyboard shortcuts

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