ioc

package
v1.19.22 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: MIT Imports: 15 Imported by: 115

Documentation

Index

Constants

View Source
const (
	DEFAULT_VERSION = "v1"
)

Variables

This section is empty.

Functions

func ConfigIocObject added in v1.9.20

func ConfigIocObject(req *LoadConfigRequest) error

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 ValidateFileType added in v1.9.20

func ValidateFileType(ext string) error

func ValidateIocObject added in v1.9.19

func ValidateIocObject(obj Object) error

Types

type ConfigEnv added in v1.9.20

type ConfigEnv struct {
	Enabled bool
	Prefix  string
}

type ConfigFile added in v1.9.20

type ConfigFile struct {
	Enabled bool
	Path    string
}

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 LoadConfigRequest added in v1.9.20

type LoadConfigRequest struct {
	// 环境变量配置
	ConfigEnv *ConfigEnv
	// 文件配置方式
	ConfigFile *ConfigFile
}

func NewLoadConfigRequest added in v1.9.20

func NewLoadConfigRequest() *LoadConfigRequest

type NamespaceStore added in v1.9.20

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

func (*NamespaceStore) Close added in v1.9.20

func (s *NamespaceStore) Close() error

func (*NamespaceStore) First added in v1.9.20

func (s *NamespaceStore) First() Object

第一个

func (*NamespaceStore) ForEach added in v1.9.20

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

func (*NamespaceStore) Get added in v1.9.20

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

func (*NamespaceStore) Init added in v1.9.20

func (s *NamespaceStore) Init() error

func (*NamespaceStore) Last added in v1.9.20

func (s *NamespaceStore) Last() Object

最后一个

func (*NamespaceStore) Len added in v1.9.20

func (s *NamespaceStore) Len() int

func (*NamespaceStore) Less added in v1.9.20

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

func (*NamespaceStore) LoadFromEnv added in v1.9.20

func (i *NamespaceStore) LoadFromEnv(prefix string) error

从环境变量中加载对象配置

func (*NamespaceStore) LoadFromFile added in v1.9.20

func (i *NamespaceStore) LoadFromFile(filename string) error

func (*NamespaceStore) ObjectUids added in v1.9.20

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

func (*NamespaceStore) Registry added in v1.9.20

func (s *NamespaceStore) Registry(obj Object)

func (*NamespaceStore) SetPriority added in v1.9.20

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

func (*NamespaceStore) Sort added in v1.9.20

func (s *NamespaceStore) Sort()

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

func (*NamespaceStore) Swap added in v1.9.20

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

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 ObjectImpl added in v1.9.20

type ObjectImpl struct {
}

func (*ObjectImpl) AllowOverwrite added in v1.9.20

func (i *ObjectImpl) AllowOverwrite() bool

func (*ObjectImpl) Destory added in v1.9.20

func (i *ObjectImpl) Destory()

func (*ObjectImpl) Init added in v1.9.20

func (i *ObjectImpl) Init() error

func (*ObjectImpl) Name added in v1.9.20

func (i *ObjectImpl) Name() string

func (*ObjectImpl) Priority added in v1.9.20

func (i *ObjectImpl) Priority() int

func (*ObjectImpl) Version added in v1.9.20

func (i *ObjectImpl) Version() string

type StoreManage added in v1.9.20

type StoreManage interface {
	// 遍历对象
	ForEach(fn func(Object))
	// 从环境变量中加载对象配置
	LoadFromEnv(prefix string) error
}

type StoreUser added in v1.9.20

type StoreUser interface {
	// 对象注册
	Registry(obj Object)
	// 对象获取
	Get(name string, opts ...GetOption) Object
}

func Api added in v1.9.19

func Api() StoreUser

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

func Config added in v1.9.19

func Config() StoreUser

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

func Controller added in v1.9.19

func Controller() StoreUser

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

func Default added in v1.9.19

func Default() StoreUser

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

type Stroe added in v1.9.20

type Stroe interface {
	StoreUser
	StoreManage
}

Directories

Path Synopsis
apps
config

Jump to

Keyboard shortcuts

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