Documentation
¶
Overview ¶
DigiStratum GoLib - Dependency Injection
Index ¶
- Constants
- func NewDependencies(deps ...DependencyIfc) *dependencies
- func NewDependency(name string) *dependency
- func NewDependencyInstance(name string, instance interface{}) *dependencyInstance
- type DependenciesIfc
- type DependencyCaptureFunc
- type DependencyIfc
- type DependencyInjectable
- func (r *DependencyInjectable) AddDeclaredDependencies(deps ...DependencyIfc) *DependencyInjectable
- func (r *DependencyInjectable) GetDeclaredDependencies() DependenciesIfc
- func (r *DependencyInjectable) GetInjectedDependencies() DependenciesIfc
- func (r *DependencyInjectable) GetInstance(name string) interface{}
- func (r *DependencyInjectable) GetInstanceVariant(name, variant string) interface{}
- func (r *DependencyInjectable) GetMissingDependencies() DependenciesIfc
- func (r *DependencyInjectable) GetOptionalDependencies() DependenciesIfc
- func (r *DependencyInjectable) GetOptionalDependencyInstances() []dependencyInstance
- func (r *DependencyInjectable) GetRequiredDependencies() DependenciesIfc
- func (r *DependencyInjectable) GetRequiredDependencyInstances() []dependencyInstance
- func (r *DependencyInjectable) GetUnknownDependencies() DependenciesIfc
- func (r *DependencyInjectable) GetUnknownDependencyInstances() []dependencyInstance
- func (r *DependencyInjectable) HasAllRequiredDependencies() bool
- func (r *DependencyInjectable) InjectDependencies(depinst ...DependencyInstanceIfc) error
- func (r *DependencyInjectable) Start() error
- type DependencyInjectableIfc
- type DependencyInstanceIfc
Constants ¶
const DEP_VARIANT_DEFAULT = "default"
Variables ¶
This section is empty.
Functions ¶
func NewDependencies ¶
func NewDependencies(deps ...DependencyIfc) *dependencies
Make a new one of these!
func NewDependency ¶
func NewDependency(name string) *dependency
func NewDependencyInstance ¶
func NewDependencyInstance(name string, instance interface{}) *dependencyInstance
Types ¶
type DependenciesIfc ¶
type DependenciesIfc interface {
// Add one or more Dependencies to the set
Add(deps ...DependencyIfc) *dependencies
// Get a dependency by name/variant
Get(name string) DependencyIfc
GetVariant(name, variant string) DependencyIfc
// Check whether a dependency is in the set by name/variant
Has(name string) bool
HasVariant(name, variant string) bool
// Get the list of currently set dependencies
GetVariants(name string) []string
GetAllVariants() map[string][]string
}
type DependencyCaptureFunc ¶
type DependencyCaptureFunc func(instance interface{}) bool
return true on success, false on error (i.e. interface assertion failure)
type DependencyIfc ¶
type DependencyInjectable ¶
Exported to support embedding
func NewDependencyInjectable ¶
func NewDependencyInjectable(deps ...DependencyIfc) *DependencyInjectable
Make a new one of these
func (*DependencyInjectable) AddDeclaredDependencies ¶
func (r *DependencyInjectable) AddDeclaredDependencies(deps ...DependencyIfc) *DependencyInjectable
Add more Dependency declarations
func (*DependencyInjectable) GetDeclaredDependencies ¶
func (r *DependencyInjectable) GetDeclaredDependencies() DependenciesIfc
What are all the declared Dependecies?
func (*DependencyInjectable) GetInjectedDependencies ¶
func (r *DependencyInjectable) GetInjectedDependencies() DependenciesIfc
What are the injected DependencyInstances?
func (*DependencyInjectable) GetInstance ¶
func (r *DependencyInjectable) GetInstance(name string) interface{}
Get the injected dependency matching name (default or any variant)
func (*DependencyInjectable) GetInstanceVariant ¶
func (r *DependencyInjectable) GetInstanceVariant(name, variant string) interface{}
Get the injected dependency matching name and specific variant
func (*DependencyInjectable) GetMissingDependencies ¶
func (r *DependencyInjectable) GetMissingDependencies() DependenciesIfc
What Dependencies are Required that have not yet been injected?
func (*DependencyInjectable) GetOptionalDependencies ¶
func (r *DependencyInjectable) GetOptionalDependencies() DependenciesIfc
What are just the optional Dependencies?
func (*DependencyInjectable) GetOptionalDependencyInstances ¶
func (r *DependencyInjectable) GetOptionalDependencyInstances() []dependencyInstance
Get the injected, optional Dependency Instances
func (*DependencyInjectable) GetRequiredDependencies ¶
func (r *DependencyInjectable) GetRequiredDependencies() DependenciesIfc
What are just the required Dependencies?
func (*DependencyInjectable) GetRequiredDependencyInstances ¶
func (r *DependencyInjectable) GetRequiredDependencyInstances() []dependencyInstance
Get the injected, required Dependency Instances
func (*DependencyInjectable) GetUnknownDependencies ¶
func (r *DependencyInjectable) GetUnknownDependencies() DependenciesIfc
What Dependencies are injected, but unknown (undeclared) to us?
func (*DependencyInjectable) GetUnknownDependencyInstances ¶
func (r *DependencyInjectable) GetUnknownDependencyInstances() []dependencyInstance
Get the injected, unknown Dependency Instances
func (*DependencyInjectable) HasAllRequiredDependencies ¶
func (r *DependencyInjectable) HasAllRequiredDependencies() bool
Have all required dependencies have been injected?
func (*DependencyInjectable) InjectDependencies ¶
func (r *DependencyInjectable) InjectDependencies(depinst ...DependencyInstanceIfc) error
Receive dependency injection from external source
func (*DependencyInjectable) Start ¶
func (r *DependencyInjectable) Start() error
Starter func; ensure that all required dependencies are injected
type DependencyInjectableIfc ¶
type DependencyInjectableIfc interface {
// Embedded interface(s)
startable.StartableIfc
// Our own interface
AddDeclaredDependencies(deps ...DependencyIfc) *DependencyInjectable
// Injection & Retrieval
// Receive dependency injection from external source
InjectDependencies(depinst ...DependencyInstanceIfc) error
// Have all required dependencies have been injected?
HasAllRequiredDependencies() bool
// Discovery (Declared)
// What are all the declared Dependecies?
GetDeclaredDependencies() DependenciesIfc
// What are just the required Dependencies?
GetRequiredDependencies() DependenciesIfc
// What are just the optional Dependencies?
GetOptionalDependencies() DependenciesIfc
// Discovery (Injected)
// What are the injected DependencyInstances?
GetInjectedDependencies() DependenciesIfc
// What Dependencies are Required that have not yet been injected?
GetMissingDependencies() DependenciesIfc
// What Dependencies are injected, but unknown (undeclared) to us?
GetUnknownDependencies() DependenciesIfc
// Retrieval (Injected)
// Get the injected dependency matching name (default or any variant)
GetInstance(name string) interface{}
// Get the injected dependency matching name and specific variant
GetInstanceVariant(name, variant string) interface{}
// Get the injected, required Dependency Instances
GetRequiredDependencyInstances() []dependencyInstance
// Get the injected, optional Dependency Instances
GetOptionalDependencyInstances() []dependencyInstance
// Get the injected, unknown Dependency Instances
GetUnknownDependencyInstances() []dependencyInstance
}
Implementation can consume injected DependencyInstanceIfc's