Documentation ¶
Overview ¶
Package plumbing defines generic types for the dependency injection mechanisms in rig.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
Factory is a function that takes a parameter of type R and returns a value of type T or an error.
type LazyService ¶
LazyService is a generic lazy-initializer for a provider that can take a different types of parameter.
func NewLazyService ¶
func NewLazyService[S any, T any](p provider[S, T], source S) *LazyService[S, T]
NewLazyService creates a new instance of Service with the given provider.
func (*LazyService[R, T]) Get ¶
func (s *LazyService[R, T]) Get() (T, error)
Get retrieves the service value, initializing it if necessary.
type Provider ¶
Provider is a generic provider of values of type T that can be initialized with a value of type R.
func NewProvider ¶
NewProvider creates a new instance of Provider. The error is returned if no factory can produce a value of type T.
func (*Provider[R, T]) Get ¶
Get retrieves the first value of type T from the Factories in the Provider. If none can be found, the error supplied at creation time is returned. The first factory that does not error is moved to the front of the list to optimize future lookups.