framework

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: Apache-2.0 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 绑定一个服务提供者,如果关键字凭证已经存在,会进行替换
	Bind(provider ServiceProvider) error
	// IsBind 关键字凭证是否已绑定服务提供者
	IsBind(key string) bool
	// Make 根据关键字凭证获取一个服务提供者
	Make(key string) (any, error)
	// MustMake 根据关键字凭证获取一个服务,如果这个关键字凭证未绑定服务提供者,那么panic
	MustMake(key string) any
	// MakeNew 根据关键字凭证获取一个服务,只是这个服务并不是单例的
	// 它是根据服务提供者注册的启动函数和传递的params参数实例化出来的
	// 这个函数在需要为不同参数启动不同实例时候非常有用
	MakeNew(key string, params []any) (any, error)
}

type NewInstance

type NewInstance func(...any) (any, error)

type ServiceProvider

type ServiceProvider interface {
	// Register 在服务容器中注册了一个实例化服务方法
	Register(Container) NewInstance
	// Boot 在调用实例化服务的时候,做一些准备工作
	Boot(Container) error
	// IsDefer 是否在注册的时候实例化服务
	IsDefer() bool
	// Params 传递给NewInstance的参数
	Params(Container) []any
	// Name 服务提供者凭证
	Name() string
}

type WebContainer

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

func NewWebContainer

func NewWebContainer() *WebContainer

func (*WebContainer) Bind

func (con *WebContainer) Bind(provider ServiceProvider) error

func (*WebContainer) IsBind

func (con *WebContainer) IsBind(key string) bool

func (*WebContainer) Make

func (con *WebContainer) Make(key string) (any, error)

func (*WebContainer) MakeNew

func (con *WebContainer) MakeNew(key string, parmas []any) (any, error)

func (*WebContainer) MustMake

func (con *WebContainer) MustMake(key string) any

func (*WebContainer) NameList

func (con *WebContainer) NameList() []string

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
log

Jump to

Keyboard shortcuts

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