Documentation
¶
Index ¶
- func NewProviderFromIdxMap[P Provider, C Configurable](ctx context.Context, config C, factories IdxMap[ProviderFactory[P, C]], ...) (p P, err error)
- type Configurable
- type CreatorFunc
- type Factory
- type Id
- type Idx
- type IdxMap
- type IdxService
- type NewProviderFunc
- type Provider
- type ProviderFactory
- type Registry
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProviderFromIdxMap ¶
func NewProviderFromIdxMap[P Provider, C Configurable]( ctx context.Context, config C, factories IdxMap[ProviderFactory[P, C]], key string, ) (p P, err error)
NewProviderFromNamedMap creates a provider instance from a factory map using the given key
Types ¶
type Configurable ¶
type Configurable interface {
// Check if config is valid.
Validate() error
}
Configurable defines an interface that configs must implement.
type CreatorFunc ¶
type CreatorFunc func() Configurable
CreatorFunc is a function that returns a new Configurable.
type Factory ¶
type Factory interface {
Idx
NewConfig() Configurable
}
Config defines something that expose its uique name.
func NewFactory ¶
func NewFactory(id Id, cf CreatorFunc) Factory
NewFactory returns a new Factory instance.
type IdxMap ¶
type IdxMap[T Idx] struct { // contains filtered or unexported fields }
func MustNewIdxMap ¶
func (*IdxMap[T]) GetInOrder ¶
func (i *IdxMap[T]) GetInOrder() []T
type IdxService ¶
func NewIdxService ¶
func NewIdxService(id Id, service Service) IdxService
type NewProviderFunc ¶
type NewProviderFunc[P Provider, C Configurable] func(ctx context.Context, config C) (P, error)
NewProviderFunc defines a function that creates a new provider
type ProviderFactory ¶
type ProviderFactory[P Provider, C Configurable] interface { Idx New(context.Context, C) (P, error) }
ProviderFactory defines an interface for a typed provider factory
func NewProviderFactory ¶
func NewProviderFactory[P Provider, C Configurable](id Id, fn NewProviderFunc[P, C]) ProviderFactory[P, C]
NewProviderFactory returns a new generic provider factory
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry(services ...IdxService) (*Registry, error)
Click to show internal directories.
Click to hide internal directories.