Documentation ¶
Index ¶
- Variables
- func Declare[T any](ptr *T, constructor func() (*T, error), deps ...any)
- func DeclareOnGraph[T any](g Graph, ptr *T, constructor func() (*T, error), deps ...any)
- func Init() error
- func InitGraph(g Graph) error
- func LazyLoad[T, I any](ptr *T) (cb func() (I, error))
- func LazyLoadFromGraph[T, I any](g Graph, ptr *T) (cb func() (I, error))
- func Load[T any](ptr *T) error
- func LoadFromGraph[T any](g Graph, ptr *T) error
- type Graph
Constants ¶
This section is empty.
Variables ¶
var DefaultGraph = make(Graph)
var (
ErrInvalidConstructor = errors.New("constructor must return non-nil value if there is no error")
)
Functions ¶
func DeclareOnGraph ¶
DeclareOnGraph - declare a node to initialize on a graph. Non-blocking operation.
func LazyLoad ¶ added in v0.1.2
LazyLoad - a helper function, wrapping Load. The idea is to initialize something and all it's dependencies without knowing what's the concrete type of it.
func LazyLoadFromGraph ¶ added in v0.1.2
LazyLoadFromGraph - a helper function, wrapping LoadFromGraph. The idea is to initialize something and all it's dependencies without knowing what's the concrete type of it.
func LoadFromGraph ¶ added in v0.1.2
LoadFromGraph - initialize a node from a graph and all it's dependencies. Blocking operation.
Types ¶
type Graph ¶
type Graph map[string]*graphNode
Graph - dependency graph. Has no public methods as it shouldn't be used directly. However, it is exported to allow custom dependency graphs to be used with DeclareOnGraph and InitGraph methods:
var g = make(indi.Graph) indi.DeclareOnGraph(g, ...) ... indi.InitGraph(g)