Documentation
¶
Index ¶
- type Binding
- func (b *Binding) BindParams() []reflect.Value
- func (b *Binding) Dependencies() []reflect.Type
- func (b *Binding) DependencyNames() iter.Seq[string]
- func (b *Binding) GetName() string
- func (b *Binding) GetOrSetConcrete(factory func(b *Binding, params []reflect.Value) (any, error), ...) (any, error)
- func (b *Binding) HasConcrete() bool
- func (b *Binding) IsSingleton() bool
- func (b *Binding) NamedBindings() []string
- func (b *Binding) Resolver() any
- type Registrar
- func (r *Registrar) Delete(t reflect.Type, name string)
- func (r *Registrar) Find(abstraction reflect.Type, name string) (*Binding, bool)
- func (r *Registrar) FindSlot(abstraction reflect.Type, name string) (Slot, bool)
- func (r *Registrar) Get(t reflect.Type, name string) (*Binding, bool)
- func (r *Registrar) Registrations() []Registration
- func (r *Registrar) Reset()
- func (r *Registrar) Set(t reflect.Type, name string, b *Binding) error
- func (r *Registrar) SetIfAbsent(t reflect.Type, name string, b *Binding) (wasNew bool, err error)
- type Registration
- type Slot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binding ¶
type Binding struct {
// contains filtered or unexported fields
}
Binding holds a resolver and a concrete (if already resolved). It is the break for the Container wall!
func NewBinding ¶
func NewBinding( name string, isSingleton bool, bindParams []reflect.Value, namedBindings []string, resolver any, concrete any, ) *Binding
NewBinding creates and returns a new Binding instance.
func (*Binding) BindParams ¶
BindParams returns the parameters specified at bind time for dependency resolution.
func (*Binding) Dependencies ¶ added in v1.2.0
Dependencies returns the resolver inputs left unsatisfied by the parameters given at bind time, worked out once since neither of the two ever changes.
func (*Binding) DependencyNames ¶ added in v1.2.0
DependencyNames yields the names to look a dependency up under, in the order the container tries them.
func (*Binding) GetOrSetConcrete ¶
func (b *Binding) GetOrSetConcrete( factory func(b *Binding, params []reflect.Value) (any, error), params []reflect.Value, ) (any, error)
GetOrSetConcrete returns the existing concrete if set, otherwise calls factory exactly once to create it. Safe for concurrent use.
func (*Binding) HasConcrete ¶
HasConcrete checks if the Binding has a concrete instance.
func (*Binding) IsSingleton ¶
IsSingleton specifies whether the Binding is a singleton.
func (*Binding) NamedBindings ¶
NamedBindings returns the named Bindings specified at bind time for dependency resolution.
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
Registrar manages binding registerations. It is the way in to the store holding them and to the acyclic guard deciding what may join it, and owns the lock the two are used under.
func NewRegisterar ¶
func NewRegisterar() *Registrar
NewRegisterar creates and returns a new Registrar instance.
func (*Registrar) Find ¶
Find retrieves a binding by exact type match, falling back to interface-implementation lookup.
func (*Registrar) FindSlot ¶ added in v1.2.0
FindSlot is like Find but returns the slot holding the match instead of the binding.
func (*Registrar) Registrations ¶ added in v1.2.0
func (r *Registrar) Registrations() []Registration
Registrations returns a snapshot of every registration, in the order the slots were first registered.
type Registration ¶ added in v1.2.0
Registration pairs a binding with the slot it is registered in.