framework

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container interface {
	// 绑定服务提供者到容器
	Bind(provider ServiceProvider) error
	// 是否已绑定服务提供者
	IsBind(key string) bool

	// 根据关键字获取一个服务
	Make(key string) (interface{}, error)
	// 如果没有绑定,panic
	MustMake(key string) interface{}
	// 为不同的参数启动不同的服务实例,不再是单例模式
	MakeNew(key string, params []interface{}) (interface{}, error)
	// 所有服务提供者的KEY
	NameList() []string
}

type NewInstance

type NewInstance func(...interface{}) (interface{}, error)

type OneContainer

type OneContainer struct {
	// 强制要求OneContainer实现Container
	Container
	// contains filtered or unexported fields
}

func NewOneContainer

func NewOneContainer() *OneContainer

func (*OneContainer) Bind

func (one *OneContainer) Bind(provider ServiceProvider) error

func (*OneContainer) IsBind

func (one *OneContainer) IsBind(key string) bool

func (*OneContainer) Make

func (one *OneContainer) Make(key string) (interface{}, error)

func (*OneContainer) MakeNew

func (one *OneContainer) MakeNew(key string, params []interface{}) (interface{}, error)

func (*OneContainer) MustMake

func (one *OneContainer) MustMake(key string) interface{}

func (*OneContainer) NameList

func (one *OneContainer) NameList() []string

NameList 列出容器中所有服务提供者的字符串凭证

type ServiceProvider

type ServiceProvider interface {
	// 获取服务凭证的方法
	Name() string
	// 注册实例化服务的方法
	Register(Container) NewInstance
	// 实例化方法需要的参数
	Params(Container) []interface{}
	// 是否延迟实例化
	IsDefer() bool
	// 实例化之前的准备工作
	Boot(Container) error
}

Directories

Path Synopsis
Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
doc
gin
Package gin implements a HTTP web framework called gin.
Package gin implements a HTTP web framework called gin.
provider
app
env
id
log

Jump to

Keyboard shortcuts

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