component

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StepUndefinedError = errors.New("step is undefined")
)

Functions

This section is empty.

Types

type BindFlags

type BindFlags func(flagSet flag.FlagSet, container container.Container) error

BindFlags defines a function for registering command-line flags. Called during the flag binding phase before any step execution.

type Component

type Component struct {
	// Name component in core logs
	Name string

	// Dependencies lists other components that must be initialized before this one
	Dependencies Components

	// Init performs initial setup and registers services in the container
	Init StepFunc

	Configuration StepFunc

	// BindFlags registers component-specific command-line flags
	BindFlags BindFlags

	// PreExecute executes before the main Execute step
	PreExecute StepFunc

	ExecuteDuration GetDurationFunc
	// Execute contains the main component logic
	Execute StepFunc
	// PostExecute executes after the main Execute step
	PostExecute StepFunc

	// PreWait executes before entering wait state
	PreWait StepFunc
	// Wait typically blocks for signals or async operations
	Wait WaitFunc
	// PostWait executes after wait state
	PostWait StepFunc

	// PreStop executes before shutdown
	PreStop StepFunc
	// Stop performs cleanup and graceful shutdown
	Stop StepFunc
	// PostStop executes after shutdown is complete
	PostStop StepFunc
}

Component represents a modular piece of application logic with a defined lifecycle. Each component can declare dependencies and hook into various execution steps.

func (*Component) GetStepFunc added in v0.0.25

func (c *Component) GetStepFunc(step Step) (StepFunc, error)

type Components

type Components []*Component

Components is a collection of Component pointers for easier grouping.

type GetDurationFunc

type GetDurationFunc func() time.Duration

type Step

type Step uint8
const (
	Init Step = iota
	BindFlag
	Configuration

	PreExecute
	Execute
	PostExecute

	PreWait
	Wait
	PostWait

	PreStop
	Stop
	PostStop
)

func (Step) String

func (i Step) String() string

type StepFunc

type StepFunc func(container container.Container) error

StepFunc defines a function that executes at a specific lifecycle step. It receives the DI container which should already contain all initialized dependencies.

type WaitFunc

type WaitFunc func(ctx context.Context, container container.Container) error

Jump to

Keyboard shortcuts

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