Documentation
¶
Index ¶
- type Binding
- func (b *Binding) BindParams() []reflect.Value
- func (b *Binding) Concrete() any
- 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) HasName() bool
- func (b *Binding) IsSingleton() bool
- func (b *Binding) NamedBindings() []string
- func (b *Binding) Resolver() any
- func (b *Binding) SetConcrete(concrete 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) Get(t reflect.Type, name string) (*Binding, bool)
- 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)
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) Concrete ¶
Concrete returns the concrete instance of the Binding if it is a singleton and has been resolved, otherwise it returns nil.
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.
func (*Binding) SetConcrete ¶
SetConcrete sets the concrete instance of the Binding. Safe for concurrent use.
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
Registrar manages binding registerations.
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.