spicegen

package
v0.0.0-...-6d561a7 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess = 0
	ExitFailure = 1
	ExitUsage   = 2
)

Variables

This section is empty.

Functions

func ConfigurationSchema

func ConfigurationSchema() (spiceconfig.Schema, error)

func Main

func Main(arguments []string) int

func RunCommand

func RunCommand(options CommandOptions) int

Types

type Application

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

func NewApplication

func NewApplication(ctx context.Context, observers ...spicelifecycle.Observer) (*Application, error)

func NewApplicationWithOptions

func NewApplicationWithOptions(ctx context.Context, options ApplicationOptions) (*Application, error)

func (*Application) Components

func (application *Application) Components() Components

Components returns a typed snapshot of constructed singleton beans.

func (*Application) Handler

func (application *Application) Handler() http.Handler

func (*Application) RegisterObserver

func (application *Application) RegisterObserver(observer spicelifecycle.Observer) error

func (*Application) Run

func (application *Application) Run(ctx context.Context, shutdown spicelifecycle.ContextFactory) error

func (*Application) ShutdownTimeout

func (application *Application) ShutdownTimeout() time.Duration

func (*Application) Start

func (application *Application) Start(ctx context.Context) error

func (*Application) State

func (application *Application) State() spicelifecycle.State

func (*Application) Stop

func (application *Application) Stop(ctx context.Context) error

type ApplicationOptions

type ApplicationOptions struct {
	Overrides                 BeanOverrides
	Profiles                  []string
	Sources                   []spiceconfig.Source
	AllowUnknownConfiguration bool
	ErrorMapper               spiceweb.ErrorMapper
	MaxRequestBodyBytes       int64
	HTTPObservers             []spiceweb.HTTPObserver
	Middleware                []spiceweb.Middleware
	Interceptors              RouteInterceptors
	Logger                    *slog.Logger
	Observers                 []spicelifecycle.Observer
}

type BeanOverrideLayer

type BeanOverrideLayer struct {
	Name      string
	Overrides BeanOverrides
}

BeanOverrideLayer is one named immutable override composition layer. Layers are applied in order; a later layer deliberately replaces an earlier value.

type BeanOverrides

type BeanOverrides struct {
	// Catalog replaces bean "newCatalog".
	Catalog spicebean.Override[*i18n.Catalog]
	// Renderer replaces bean "newRenderer".
	Renderer spicebean.Override[*spiceview.Renderer]
	// Mux replaces bean "newMux".
	Mux spicebean.Override[*http.ServeMux]
	// WelcomeController replaces bean "welcomeController".
	WelcomeController spicebean.Override[*system.WelcomeController]
	// OpenDatabase replaces bean "openDatabase".
	OpenDatabase spicebean.Override[*postgres.Database]
	// VetRepository replaces bean "vetRepository".
	VetRepository spicebean.Override[*postgres.VetRepository]
	// VetController replaces bean "controller".
	VetController spicebean.Override[*vet.Controller]
	// OwnerRepository replaces bean "ownerRepository".
	OwnerRepository spicebean.Override[*postgres.OwnerRepository]
	// OwnerController replaces bean "controller".
	OwnerController spicebean.Override[*owner.Controller]
	// VisitController replaces bean "visitController".
	VisitController spicebean.Override[*owner.VisitController]
	// PetTypeRepository replaces bean "petTypeRepository".
	PetTypeRepository spicebean.Override[*postgres.PetTypeRepository]
	// PetController replaces bean "petController".
	PetController spicebean.Override[*owner.PetController]
	// Server replaces bean "newServer".
	Server spicebean.Override[*presentation.Server]
}

BeanOverrides provides compile-time-typed singleton replacements. Replacements use the normal generated cleanup and rollback path.

func ComposeBeanOverrides

func ComposeBeanOverrides(layers ...BeanOverrideLayer) (BeanOverrides, error)

ComposeBeanOverrides validates and deterministically composes named layers. It never mutates a running application or performs runtime bean lookup.

type CommandOptions

type CommandOptions struct {
	Context         context.Context
	Arguments       []string
	Stdout          io.Writer
	Stderr          io.Writer
	Logger          *slog.Logger
	ShutdownTimeout time.Duration
	ShutdownContext ShutdownContextFactory
	Application     ApplicationOptions
}

type Components

type Components struct {
	// Catalog is bean "newCatalog".
	Catalog *i18n.Catalog
	// Renderer is bean "newRenderer".
	Renderer *spiceview.Renderer
	// Mux is bean "newMux".
	Mux *http.ServeMux
	// WelcomeController is bean "welcomeController".
	WelcomeController *system.WelcomeController
	// Settings is bean "Settings".
	Settings postgres.Settings
	// OpenDatabase is bean "openDatabase".
	OpenDatabase *postgres.Database
	// VetRepository is bean "vetRepository".
	VetRepository *postgres.VetRepository
	// VetController is bean "controller".
	VetController *vet.Controller
	// OwnerRepository is bean "ownerRepository".
	OwnerRepository *postgres.OwnerRepository
	// OwnerController is bean "controller".
	OwnerController *owner.Controller
	// VisitController is bean "visitController".
	VisitController *owner.VisitController
	// PetTypeRepository is bean "petTypeRepository".
	PetTypeRepository *postgres.PetTypeRepository
	// PetController is bean "petController".
	PetController *owner.PetController
	// ServerSettings is bean "ServerSettings".
	ServerSettings presentation.ServerSettings
	// Server is bean "newServer".
	Server *presentation.Server
}

Components is a typed snapshot of constructed singleton beans. It performs no reflection or string-based lookup.

type RouteInterceptors

RouteInterceptors configures typed generated route method decorators. The first interceptor in each field is the outermost invocation.

type ShutdownContextFactory

type ShutdownContextFactory func(time.Duration) (context.Context, context.CancelFunc)

Directories

Path Synopsis
sources
vet

Jump to

Keyboard shortcuts

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