ioc

package
v0.0.0-...-20679a4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivatorFunc

type ActivatorFunc func(params ...interface{}) (interface{}, error)

ActivatorFunc creates a new instance of specified type.

type Container

type Container interface {
	// Add inserts the instance creation activator with the type value.
	Add(t InstanceType, activator ActivatorFunc)

	// GetInstance creates new instance associated with the type value.
	GetInstance(t InstanceType, p ...interface{}) (interface{}, error)
}

Container is the ioc container. It manages the life cycle of instance creation.

type DefaultContainer

type DefaultContainer struct {
	// contains filtered or unexported fields
}

DefaultContainer implements the dependency injection container.

func New

func New() *DefaultContainer

New create a new instance of default container.

func (*DefaultContainer) Add

func (c *DefaultContainer) Add(t InstanceType, activator ActivatorFunc)

Add inserts the instance creation activator in the container.

func (*DefaultContainer) GetInstance

func (c *DefaultContainer) GetInstance(t InstanceType, params ...interface{}) (interface{}, error)

GetInstance creates new instance of the specified type value.

type InstanceType

type InstanceType uint16

InstanceType represents the instance type enum.

const (
	// InstanceTypeAuth is the enum member of type auth.
	InstanceTypeAuth InstanceType = iota

	// InstanceTypeUserinfo is the enum member of type userinfo.
	InstanceTypeUserinfo

	// InstanceTypeNotestore is the enum member of type notestore.
	InstanceTypeNotestore

	// InstanceTypeSectionstore is the enum member of type sectionstore.
	InstanceTypeSectionstore
)

Jump to

Keyboard shortcuts

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