starter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package starter provides auto-configuration modules (web, data, security, observability) for the Helix framework.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidStarter = errors.New("invalid starter")

ErrInvalidStarter is returned when a starter Entry fails validation.

Functions

func Configure

func Configure(container *core.Container, entries []Entry, opts ...Option) error

Configure evaluates and activates each starter in canonical order. Validation errors are returned before any Configure call is made.

func ConfigureMarkerAware

func ConfigureMarkerAware(container *core.Container, entries []Entry, opts ...Option) error

ConfigureMarkerAware evaluates and activates marker-aware starters after application components have been registered in the container. It only processes starters that implement MarkerAwareStarter; others are skipped.

Types

type ActivationReason

type ActivationReason string

ActivationReason describes why a starter was activated.

const (
	// ReasonGoMod indicates the starter was activated because a dependency was
	// found in go.mod.
	ReasonGoMod ActivationReason = "go-mod"
	// ReasonConfigKey indicates the starter was activated because a matching
	// configuration key was present.
	ReasonConfigKey ActivationReason = "config-key"
	// ReasonComponentMarker indicates the starter was activated because a
	// component with the expected marker was found in the container.
	ReasonComponentMarker ActivationReason = "component-marker"
	// ReasonExplicit indicates the starter was activated because it was
	// explicitly enabled via configuration.
	ReasonExplicit ActivationReason = "explicit"
)

type Entry

type Entry struct {
	Name    string
	Order   Order
	Starter Starter
}

Entry binds a Starter to its canonical order and a human-readable name.

type MarkerAwareStarter

type MarkerAwareStarter interface {
	Starter
	ConditionFromContainer(container *core.Container) bool
}

MarkerAwareStarter is an optional extension of Starter. Starters that implement it can evaluate their activation condition after application components have been registered in the container.

Priority of evaluation (highest to lowest):

  1. enabled: false in config → never active
  2. enabled: true in config → always active
  3. ConditionFromContainer → active if container holds the expected marker
  4. Condition → default structural detection (go.mod, config key)

type Option

type Option func(*options)

Option configures the starter orchestrator.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger used to emit activation events.

type Order

type Order int

Order controls the canonical activation sequence of starters.

const (
	OrderConfig        Order = iota // 0 — configuration must be first
	OrderWeb                        // 1
	OrderData                       // 2
	OrderObservability              // 3
	OrderSecurity                   // 4
	OrderScheduling                 // 5

)

type Starter

type Starter interface {
	// Condition reports whether this starter should be activated.
	Condition() bool
	// Configure registers components into the DI container.
	// It returns an error if configuration fails — for example when a required
	// dependency is missing or a component cannot be registered.
	Configure(*core.Container) error
}

Starter is the contract that auto-configuration modules must implement.

Directories

Path Synopsis
internal
starterutil
Package starterutil provides shared helpers for Helix starters.
Package starterutil provides shared helpers for Helix starters.

Jump to

Keyboard shortcuts

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