Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface {
Name() string
Start(ctx context.Context, wg *sync.WaitGroup) error
Stop(ctx context.Context) error
}
Component represents a startable/stoppable application component.
func NewSimpleComponent ¶
NewSimpleComponent creates a Component adapter from a Startable.
type ComponentEntry ¶
ComponentEntry pairs a component with its startup priority.
type ErrorComponent ¶
type ErrorComponent struct {
ComponentName string
StartFunc func(ctx context.Context) error
StopFunc func()
}
ErrorComponent adapts components with Start(context.Context) error / Stop() signatures.
func (*ErrorComponent) Name ¶
func (c *ErrorComponent) Name() string
type FuncComponent ¶
type FuncComponent struct {
ComponentName string
StartFunc func(ctx context.Context, wg *sync.WaitGroup) error
StopFunc func(ctx context.Context) error
}
FuncComponent wraps arbitrary start/stop functions.
func NewFuncComponent ¶
func NewFuncComponent( name string, startFn func(ctx context.Context, wg *sync.WaitGroup) error, stopFn func(ctx context.Context) error, ) *FuncComponent
NewFuncComponent creates a Component from start/stop functions.
func (*FuncComponent) Name ¶
func (c *FuncComponent) Name() string
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages component lifecycle with ordered startup and reverse shutdown.
func (*Registry) Names ¶ added in v0.6.0
Names returns the names of all registered components in registration order.
type SimpleComponent ¶
type SimpleComponent struct {
ComponentName string
StartFunc func(wg *sync.WaitGroup)
StopFunc func()
}
SimpleComponent adapts components with Start(*sync.WaitGroup) / Stop() signatures.
func (*SimpleComponent) Name ¶
func (c *SimpleComponent) Name() string