Documentation
¶
Overview ¶
ice is a lightweight Dependency Injection Framework
ice's cenral metaphor is a "Magic Bag".
It's a Bag because you put things in and then take things out.
Imagine a bag where you put in building materials and an Ikea instruction manual, and then you pull out a fully-formed desk. The bag did the assembly! Magic!
ice works not with Noric flat pack furniture but with Go. Our object graph is composed of Go values (the nodes) and Providers (the edges).
Lifecycle ¶
- Create an Empty Bag
- Insert Provider Functions a) or a Module, which can insert many Provider at once
- Extract Values
Terms ¶
Key: what ice knows how to create. Currently a Go type, but this may be extended.
Provider: a function that creates a foo. It may either return foo or (foo, error).
Magic Bag: binds Keys to Providers.
Extract: Use the bindings in a Magic Bag to create and wire together complex structs
Module: utility to install multiple Providers at once
Notes ¶
ice uses reflection heavily.
(MagicBag in ice is the equivalent of Guice's Injector or Dagger 1's ObjectGraph)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InjectionError ¶
type InjectionError struct {
// contains filtered or unexported fields
}
func (*InjectionError) Error ¶
func (e *InjectionError) Error() string
func (*InjectionError) String ¶
func (e *InjectionError) String() string
type MagicBag ¶
type MagicBag struct {
// contains filtered or unexported fields
}
MagicBag binds Providers to Keys which an Evaluation can use
func NewMagicBag ¶
func NewMagicBag() *MagicBag
func (*MagicBag) Extract ¶
Extract extracts a value from the MagicBag and puts it into dest, returning any errors dest must be a pointer to a type this MagicBag knows how to construct.