ioc

package
v1.9.19 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 11 Imported by: 131

Documentation

Index

Constants

View Source
const (
	DEFAULT_VERSION = "v1"
)

Variables

This section is empty.

Functions

func InitIocObject

func InitIocObject() error

初始化对象

func ListApiObjectNames

func ListApiObjectNames() (names []string)

查询已经注册的API对象名称

func ListControllerObjectNames

func ListControllerObjectNames() (names []string)

或者注册完成的控制器

func LoadGinApi

func LoadGinApi(pathPrefix string, root gin.IRouter)

LoadGinApi 装载所有的gin app

func LoadGoRestfulApi

func LoadGoRestfulApi(pathPrefix string, root *restful.Container)

LoadHttpApp 装载所有的http app

func LoadGrpcController

func LoadGrpcController(server *grpc.Server)

LoadGrpcApp 加载所有的Grpc app

func ObjectUid added in v1.9.17

func ObjectUid(o Object) string

func RegistryApi

func RegistryApi(obj Object)

注册API对象

func RegistryController

func RegistryController(obj Object)

控制器对象注册

func RegistryObjectWithNs

func RegistryObjectWithNs(namespace string, obj Object)

注册对象

func ValidateIocObject added in v1.9.19

func ValidateIocObject(obj Object) error

Types

type GRPCControllerObject

type GRPCControllerObject interface {
	Object
	Registry(*grpc.Server)
}

GRPCService GRPC服务的实例

type GetOption added in v1.9.19

type GetOption func(*option)

func WithVersion added in v1.9.19

func WithVersion(v string) GetOption

type GinApiObject

type GinApiObject interface {
	Object
	Registry(gin.IRouter)
}

type GoRestfulApiObject

type GoRestfulApiObject interface {
	Object
	Registry(*restful.WebService)
}

type IocObjectImpl

type IocObjectImpl struct {
}

func (*IocObjectImpl) AllowOverwrite added in v1.9.19

func (i *IocObjectImpl) AllowOverwrite() bool

func (*IocObjectImpl) Destory added in v1.9.19

func (i *IocObjectImpl) Destory()

func (*IocObjectImpl) Init

func (i *IocObjectImpl) Init() error

func (*IocObjectImpl) Name

func (i *IocObjectImpl) Name() string

func (*IocObjectImpl) Priority

func (i *IocObjectImpl) Priority() int

func (*IocObjectImpl) Version added in v1.9.17

func (i *IocObjectImpl) Version() string

type Object added in v1.9.19

type Object interface {
	// 对象初始化
	Init() error
	// 对象的名称
	Name() string
	// 对象版本
	Version() string
	// 对象优先级
	Priority() int
	// 对象的销毁
	Destory()
	// 是否允许同名对象被替换, 默认不允许被替换
	AllowOverwrite() bool
}

Object 内部服务实例, 不需要暴露

func GetApi

func GetApi(name string) Object

获取API对象

func GetController

func GetController(name string) Object

获取控制器对象

func GetObjectWithNs

func GetObjectWithNs(namespace, name string) Object

获取对象

type ObjectSet added in v1.9.19

type ObjectSet struct {
	// 空间名称
	Namespace string
	// 优先级
	Priority int
	// 对象列表
	Items []Object
}

func (*ObjectSet) Close added in v1.9.19

func (s *ObjectSet) Close() error

func (*ObjectSet) First added in v1.9.19

func (s *ObjectSet) First() Object

第一个

func (*ObjectSet) ForEach added in v1.9.19

func (s *ObjectSet) ForEach(fn func(Object))

func (*ObjectSet) Get added in v1.9.19

func (s *ObjectSet) Get(name string, opts ...GetOption) Object

func (*ObjectSet) Init added in v1.9.19

func (s *ObjectSet) Init() error

func (*ObjectSet) Last added in v1.9.19

func (s *ObjectSet) Last() Object

最后一个

func (*ObjectSet) Len added in v1.9.19

func (s *ObjectSet) Len() int

func (*ObjectSet) Less added in v1.9.19

func (s *ObjectSet) Less(i, j int) bool

func (*ObjectSet) ObjectUids added in v1.9.19

func (s *ObjectSet) ObjectUids() (uids []string)

func (*ObjectSet) Registry added in v1.9.19

func (s *ObjectSet) Registry(obj Object)

func (*ObjectSet) SetPriority added in v1.9.19

func (s *ObjectSet) SetPriority(v int) *ObjectSet

func (*ObjectSet) Sort added in v1.9.19

func (s *ObjectSet) Sort()

根据对象的优先级进行排序

func (*ObjectSet) Swap added in v1.9.19

func (s *ObjectSet) Swap(i, j int)

func (*ObjectSet) UnPack added in v1.9.19

func (s *ObjectSet) UnPack() error

type ObjectStroe added in v1.9.19

type ObjectStroe interface {
	// 对象注册
	Registry(obj Object)
	// 对象获取
	Get(name string, opts ...GetOption) Object
	// 获取第一个对象
	First() Object
	// 获取最后一个对象
	Last() Object
	// 遍历对象
	ForEach(fn func(Object))
}

func Api added in v1.9.19

func Api() ObjectStroe

用于托管RestApi对象的Ioc空间, 最后初始化

func Config added in v1.9.19

func Config() ObjectStroe

用于托管配置对象的Ioc空间, 最先初始化

func Controller added in v1.9.19

func Controller() ObjectStroe

用于托管控制器对象的Ioc空间, 配置完成后初始化

func Default added in v1.9.19

func Default() ObjectStroe

默认空间, 用于托管工具类, 在控制器之前进行初始化

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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