Skip to content
standards-labPublic

About

Core SDK for Standards Lab's Go Minimal standard — layered configuration, process lifecycle, and logging.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

go-core

go-core is the Core SDK for Standards Lab's Go Elemental standard. It provides layered configuration, a dependency graph and the process lifecycle that runs it, a reactor that joins a source of occurrences to a handler, the CloudEvents envelope a domain raises its events in, a server-sent event stream reader and writer, and logging.

github.com/standards-lab/go-core is a single Go module with the process-level packages every program in the standard builds on.

Standard

go-core is the Core SDK of Go Elemental, the minimal-dependency Go standard. This README and each package's doc.go document the repository; the standard's principles it enhances are stated below. It enhances the standard's dependency line: where Go Elemental admits packages as idiomatic and stable as the standard library, this repository depends on the standard library alone.

Packages

  • config — loads configuration in layers: a base file, an environment overlay, and secrets.
  • event — the CloudEvents 1.0 envelope, its binary-content-mode codec (Encode, Decode) and its JSON-format codec (EncodeJSON, DecodeJSON), and the types a domain raises its events with: an EventKind declared with Define raises an event into a Queue, carrying the extension attributes the raise's RaiseOptions sets, and a Recorder emits the queue through a Sink into the command's own transaction, only when the command succeeds. The recorder also stamps every event with the service-wide extension attributes its Options set; when a raise sets the same name, the raise's value wins. Permanent marks a handler's error that redelivery cannot fix.
  • graph — a typed dependency graph: nodes described inertly, each a name and a constructor, placed at definition after other nodes or in groups, and a Build that constructs what the roots reach into a System of computed layers. Value and Fresh define fixed and per-Build values, and a System names its nodes by their handles. A Graph is safe for concurrent use. docs/graph-design.md gives the reasons behind the design of graph and lifecycle.
  • graph/graphtest — the test toolkit beside graph: CheckNames checks a struct of node and group handles against the names its nodes and groups were defined with.
  • lifecycle — runs a built graph System: starts its layers in order, tracks and reports readiness, watches for runtime failures, and shuts the layers down in reverse within a timeout. A value takes part through the interfaces it implements. Exec is the one-shot form a CLI command uses; Run is the long-running form a service uses.
  • logging — builds an *slog.Logger from a configuration that config loads.
  • process — the parts of a binary's main sequence that run before the program's own infrastructure exists: the signal-derived root context, pre-logger failure reporting, and the exit-code convention.
  • process/processtest — the integration toolkit: it builds a program once per suite run and runs it as a subprocess. It then waits on what a client observes, interrupts the process and reads its exit code, and relays a backing service's connection so a test can sever it. Run runs the program once and returns its stdout, stderr, and exit code.
  • reactor — joins one source of occurrences to one function for the process lifetime: a lifecycle component that drains the handling in flight at shutdown and cancels it once the Options.CancelAfter period passes. Every delivers on an interval, and Wake also delivers on each Waker.Nudge a producer calls. Gate pauses background work while an operation runs exclusively.
  • sse — reads and writes a server-sent event stream, the WHATWG text/event-stream format. NewDecoder reads any io.Reader as its bytes arrive and returns a Decoder whose Next returns each dispatched Event, its type, data, and last event ID, and whose Retry reports the reconnection time the stream last set. NewEncoder writes to any io.Writer and returns an Encoder whose Encode, Comment, and Retry each send their lines in one Write, so an HTTP writer can flush once per event.

Development

Tasks run through mise:

mise run check      # build, vet, format, fix, tidy, test, and lint, then lint-context and lint-references; writes nothing
mise run currency   # report tools, Go, requirements, and action pins behind their latest, a held one with its reason
mise run upgrade    # move every trailing pin but a held one: tools, the go directive, requirements, and action pins
mise run fmt        # format all Go source
mise run tidy       # run go mod tidy

License

Apache License 2.0.

About

Core SDK for Standards Lab's Go Minimal standard — layered configuration, process lifecycle, and logging.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages