Documentation
¶
Index ¶
- Constants
- func Run(ctx context.Context, groups ...Group) error
- func RunUntilReady(waitCtx context.Context, component Component, timeout time.Duration) error
- type Base
- func (c *Base[Config, Dependencies]) Close() error
- func (c *Base[Config, Dependencies]) Config() *Config
- func (c *Base[Config, Dependencies]) Context() context.Context
- func (c *Base[Config, Dependencies]) Dependencies() Dependencies
- func (c *Base[Config, Dependencies]) Instance() string
- func (c *Base[Config, Dependencies]) MarkReady()
- func (c *Base[Config, Dependencies]) Name() string
- func (c *Base[Config, Dependencies]) Ready() <-chan struct{}
- func (c *Base[Config, Dependencies]) Run() error
- func (c *Base[Config, Dependencies]) SetConfig(config *Config)
- func (c *Base[Config, Dependencies]) TelemetryLabels() telemetry.Labels
- func (c *Base[Config, Dependencies]) TelemetryLabelsID() prometheus.Labels
- func (c *Base[Config, Dependencies]) TelemetryLabelsIDFields() []string
- type BaseConfig
- type Component
- type Factory
- type FactoryFunc
- type Group
- type Mock
- type MockOption
- type MockOptions
Constants ¶
View Source
const Global = "Global"
Global is the instance name for the global component.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶
Base is the base implementation of a component. It provides partial, default implementations of the Component interface. It SHOULD BE used as an embedded field in the actual component implementation.
func New ¶
func New[Config any, Dependencies any](config *BaseConfig[Config, Dependencies]) *Base[Config, Dependencies]
func (*Base[Config, Dependencies]) Dependencies ¶
func (c *Base[Config, Dependencies]) Dependencies() Dependencies
func (*Base[Config, Dependencies]) Ready ¶
func (c *Base[Config, Dependencies]) Ready() <-chan struct{}
func (*Base[Config, Dependencies]) SetConfig ¶
func (c *Base[Config, Dependencies]) SetConfig(config *Config)
func (*Base[Config, Dependencies]) TelemetryLabels ¶
func (*Base[Config, Dependencies]) TelemetryLabelsID ¶
func (c *Base[Config, Dependencies]) TelemetryLabelsID() prometheus.Labels
func (*Base[Config, Dependencies]) TelemetryLabelsIDFields ¶
type BaseConfig ¶
type Component ¶
type Component interface {
// Name returns the name of the component. e.g. "KVStorage".
// It SHOULD be unique between different components.
// It will used as the telemetry info. e.g. log, metrics, etc.
Name() string
// Instance returns the instance name of the component. e.g. "kvstorage-1".
// It SHOULD be unique between different instances of the same component.
// It will used as the telemetry info. e.g. log, metrics, etc.
Instance() string
// Run starts the component.
// It blocks until the component is closed.
// It MUST be called only once.
Run() (err error)
// Ready returns a channel that is closed when the component is ready.
// Returns a chan to notify the component is ready when Run is called.
Ready() (notify <-chan struct{})
// Close closes the component.
Close() (err error)
}
Component is the interface for a component. It is used to start, stop and monitor a component. A component means it is runnable, has some async work to do. ALL exported biz structs MUST implement this interface.
type FactoryFunc ¶
type FactoryFunc[ComponentImpl Component, Config any, Dependencies any] func( instance string, config *Config, dependencies Dependencies, ) (ComponentImpl, error)
func (FactoryFunc[ComponentImpl, Config, Dependencies]) New ¶
func (f FactoryFunc[ComponentImpl, Config, Dependencies]) New( instance string, config *Config, dependencies Dependencies, ) (ComponentImpl, error)
type MockOption ¶
type MockOptions ¶
type MockOptions []MockOption
func (MockOptions) Apply ¶
func (m MockOptions) Apply(mock *Mock)
Click to show internal directories.
Click to hide internal directories.