container

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONTAINER      Keyword = "container"
	AUTOWIRE       Keyword = "autowire"
	RESOURCE       Keyword = "resource"
	TAG_SPLITER            = ";"
	TAG_KV_SPLITER         = ":"
	CONTEXT                = "CONTEXT"
)

Variables

View Source
var (
	DefaultConfig = &Config{
		AutoWired: true,
		Log:       logrus.New(),
	}
)

Functions

func DIHandler

func DIHandler(container *Container, instanceName string, funcName string, isRaw bool) func(w http.ResponseWriter, r *http.Request)

multi instance di handler

func DIRouter

func DIRouter(r mux, container *Container)

func DiFree

func DiFree(log logrus.FieldLogger, dest interface{})

func InitInstance

func InitInstance(container *Container)

func RegisterController

func RegisterController(rootPath string, instanceName string, requestMaps ...RequestMap)

func RegisterInstance

func RegisterInstance(instanceName string, instancePool *sync.Pool)

func RouterSelfCheck

func RouterSelfCheck(container *Container)

Types

type Config

type Config struct {
	// AutoWired
	// the default value of autowired
	AutoWired bool
	Log       logrus.FieldLogger
}

type Container

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

func NewContainer

func NewContainer(c ...Config) *Container

NewContainer get the new container instance if not passing the config , will init with the default config

func (*Container) CheckInstanceNameIfExist

func (s *Container) CheckInstanceNameIfExist(instanceName string) bool

CheckInstanceNameIfExist check instance name if exist if exist , return true if not exist , return false

func (*Container) DiAllFields

func (s *Container) DiAllFields(dest interface{}, injectingMap map[string]interface{})

func (*Container) DiSelfCheck

func (s *Container) DiSelfCheck(instanceName string) error

DiSelfCheck check if the registered instance is invalid

func (*Container) GetInstance

func (s *Container) GetInstance(instanceName string, injectingMap map[string]interface{}) interface{}

InstanceDISelfCheck get instance by instance name injectingMap , the dependency instance, will inject the instance in injectingMap as priority

func (*Container) InstanceDISelfCheck

func (s *Container) InstanceDISelfCheck() error

InstanceDISelfCheck self check all the instance registered exist or not

func (*Container) RegisterInstance

func (s *Container) RegisterInstance(instanceName string, instancePool *sync.Pool)

RegisterInstance register new instance if instanceName is empty will fatal if instancePool is invalid , will fatal

func (*Container) Release

func (s *Container) Release(instanceName string, instance interface{})

Release release the instance to instance pool

type Keyword

type Keyword string

type RequestMap

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

func NewRawRequestMapping

func NewRawRequestMapping(method string, path string, funcName string, handlers ...http.Handler) RequestMap

func NewRequestMapping

func NewRequestMapping(method string, path string, funcName string, handlers ...http.Handler) RequestMap

Jump to

Keyboard shortcuts

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