inject

package
v0.0.0-...-6e4230c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetServices

func GetServices(from Container, defs ...Definition) error

GetServices handles multiple service retrieval request

Types

type Container

type Container interface {
	cfg.Configurer

	// OnAfterInit register function, that will be invoked after service
	// initialization and before it will be cached and returned
	OnAfterInit(func(name string, target interface{}) error)

	// HasService returns true if service with provided name is declared
	HasService(name string) bool
	// GetService searches for service by name and writes it into target
	GetService(name string, target interface{}) error
	// Define defines new service with build function for it
	Define(name string, build func(Container) (interface{}, error))

	// MustGetService is alias for GetService, that panics on error
	MustGetService(name string, target interface{})
}

Container represents dependency injection container

func NewGraph

func NewGraph(c cfg.Configurer) Container

NewGraph builds new graph DI container

type Definition

type Definition interface {
	Name() string
	Target() interface{}
}

Definition describes service request definition

func Def

func Def(name string, target interface{}) Definition

Def builds new Definition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL