ioc

package
v1.9.17 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 10 Imported by: 131

Documentation

Index

Constants

View Source
const (
	ApiNamespace = "apis"
)
View Source
const (
	ControllerNamespace = "controllers"
)
View Source
const (
	DEFAULT_VERSION = "v1"
)
View Source
const (
	DefaultNamespace = "default"
)

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 IocObject) string

func RegistryApi

func RegistryApi(obj IocObject)

注册API对象

func RegistryController

func RegistryController(obj IocObject)

控制器对象注册

func RegistryObject

func RegistryObject(obj IocObject)

注册对象到默认空间

func RegistryObjectWithNs

func RegistryObjectWithNs(namespace string, obj IocObject)

注册对象

Types

type DefaultStore

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

func NewDefaultStore

func NewDefaultStore() *DefaultStore

func (*DefaultStore) InitIocObject

func (s *DefaultStore) InitIocObject() error

初始化托管的所有对象

func (*DefaultStore) Namespace

func (s *DefaultStore) Namespace(namespace string) *IocObjectSet

func (*DefaultStore) ShowRegistryObjectNames

func (s *DefaultStore) ShowRegistryObjectNames() (names []string)

type GRPCControllerObject

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

GRPCService GRPC服务的实例

type GinApiObject

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

type GoRestfulApiObject

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

type IocObject

type IocObject interface {
	// 对象初始化
	Init() error
	// 对象的名称
	Name() string
	// 对象版本
	Version() string
	// 对象优先级
	Priority() int
}

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

func GetApi

func GetApi(name string) IocObject

获取API对象

func GetApiWithVersion added in v1.9.17

func GetApiWithVersion(name, version string) IocObject

获取API对象并指定版本

func GetController

func GetController(name string) IocObject

获取控制器对象

func GetControllerWithVersion added in v1.9.17

func GetControllerWithVersion(name, version string) IocObject

获取控制器对象

func GetObject

func GetObject(name string) IocObject

获取默认空间对象

func GetObjectWithNs

func GetObjectWithNs(namespace, name, version string) IocObject

获取对象

type IocObjectImpl

type IocObjectImpl struct {
}

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 IocObjectSet

type IocObjectSet struct {
	Items []IocObject
}

func NewIocObjectSet

func NewIocObjectSet() *IocObjectSet

func (*IocObjectSet) Add

func (s *IocObjectSet) Add(obj IocObject)

func (*IocObjectSet) Exist

func (s *IocObjectSet) Exist(name, version string) bool

func (*IocObjectSet) Get

func (s *IocObjectSet) Get(name, version string) IocObject

func (*IocObjectSet) Len

func (s *IocObjectSet) Len() int

func (*IocObjectSet) Less

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

func (*IocObjectSet) ObjectUids added in v1.9.17

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

func (*IocObjectSet) Sort

func (s *IocObjectSet) Sort()

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

func (*IocObjectSet) Swap

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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