app

package module
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package app is the org bootstrap harness: catalog fill, env load, materialize, merge, sdi wire, and process Run.

Import github.com/omcrgnt/app/use in main to register DefaultApp and runner.Runner on unique.Global. Add an App field to AppResources only to override app config from env (ecfg block APP).

Pipeline (Pipeline, Bootstrap, Run):

fill → ecfg.LoadEnv → materialize → unique.Merge → Transform → sdi.Resolve

Breaking v0.21: Bootstrap returns *App; Pipeline.Registry is *unique.Registry; App.Serve has no registry arg; catalog fields are Configurable or ResourceFactory resources (nil *Resource ok for configurable slots).

Index

Constants

View Source
const DefaultShutdownTimeout = 5 * time.Second

Variables

This section is empty.

Functions

func DefaultApp added in v0.21.0

func DefaultApp() any

DefaultApp returns the system App resource for app/use registration.

func Run

func Run(appResources any, p Pipeline) error

Run bootstraps appResources and blocks until shutdown via resolved App.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App is the root application resource; runner.Runner is injected after sdi.Resolve.

func Bootstrap

func Bootstrap(appResources any, p Pipeline) (*App, error)

Bootstrap runs fill → LoadEnv → materialize → merge → Transform → Resolve.

func (*App) BuildConfig

func (a *App) BuildConfig() (Materializer, error)

func (*App) Deps

func (a *App) Deps() []any

func (*App) GracePeriod

func (a *App) GracePeriod() time.Duration

func (*App) Inject

func (a *App) Inject(args []any)

func (*App) Serve

func (a *App) Serve(ctx context.Context) error

Serve runs until ctx is cancelled, then stops resources via injected runner.Runner. If a starter fails, Serve stops the run context, shuts down, and returns the error.

type Configurable added in v0.21.0

type Configurable interface {
	BuildConfig() (Materializer, error)
}

Configurable is a catalog resource slot (*Resource or value) that registers a spec for env + materialize. Nil *Resource is valid: fill calls BuildConfig on a zero instance of the field type.

type Materializer added in v0.21.0

type Materializer interface {
	Build() (any, error)
}

Materializer is a config spec in the registry before materialize.

type Pipeline

type Pipeline struct {
	Registry   *unique.Registry
	EnvPrefix  string
	Transforms []res.TransformFunc
}

Pipeline configures fill → LoadEnv → materialize → merge → Transform → Resolve. Callers (typically main) must set every field explicitly; there are no package defaults.

type ResourceFactory added in v0.21.0

type ResourceFactory interface {
	NewResource() (any, error)
}

ResourceFactory is a catalog resource slot whose runtime instance is created at fill time. Nil *Resource is valid: fill calls NewResource on a zero instance of the field type.

type ShutdownTimeout

type ShutdownTimeout time.Duration

ShutdownTimeout is the grace period for App.Serve after the run context is cancelled.

func (ShutdownTimeout) Usage

func (ShutdownTimeout) Usage() string

func (ShutdownTimeout) Validate

func (d ShutdownTimeout) Validate() error

type Spec

type Spec struct {
	ShutdownTimeout ShutdownTimeout
}

Spec is the app config; Spec.Build returns *App.

func (Spec) Build

func (s Spec) Build() (any, error)

Directories

Path Synopsis
Package use registers framework defaults on unique.Global.
Package use registers framework defaults on unique.Global.

Jump to

Keyboard shortcuts

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