depinject

package
v0.0.0-...-ec7f410 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2014 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package depinject provides a simple Dependency Injector.

Dependency injection is a useful pattern that allows you to standardise and centralise the way types are constructed.

This DI container allows you to Register constructor closures for the types that you need, and Create types on demand.

With well defined constructors that use dependency injection for all required dependencies, a full dependency tree can be built up. This means that dependencies will cascade from your initial Create. You should aim to keep calls to Create to a minimum and allow dependencies to cascade.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DependencyInjector

type DependencyInjector interface {
	Register(interface{}) error
	MustRegister(interface{})
	Create(interface{}) interface{}
	CreateFromType(reflect.Type) reflect.Value
}

func NewDependencyInjector

func NewDependencyInjector() DependencyInjector

NewDependencyInjector returns a new DependencyInjector

type ServiceContainer

type ServiceContainer interface {
	DependencyInjector
}

ServiceContainer is a type of DependencyInjector that caches instances

func NewServiceContainer

func NewServiceContainer() ServiceContainer

NewServiceContainer returns a new ServiceContainer

Jump to

Keyboard shortcuts

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