 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- Variables
- func ApiPathPrefix(pathPrefix string, obj Object) string
- func ConfigIocObject(req *LoadConfigRequest) error
- func DevelopmentSetup()
- func DevelopmentSetupWithPath(path string)
- func GetIocObjectUid(obj Object) (name, version string)
- func IsFileExists(filename string) bool
- func ObjectUid(o *ObjectWrapper) string
- func ValidateFileType(ext string) error
- type GetOption
- type InjectTag
- type LoadConfigRequest
- type NamespaceStore
- func (i *NamespaceStore) Autowire() error
- func (s *NamespaceStore) Close(ctx context.Context)
- func (s *NamespaceStore) Count() int
- func (s *NamespaceStore) First() Object
- func (s *NamespaceStore) ForEach(fn func(*ObjectWrapper))
- func (s *NamespaceStore) Get(name string, opts ...GetOption) Object
- func (s *NamespaceStore) ImplementInterface(objType reflect.Type, opts ...GetOption) (objs []Object)
- func (s *NamespaceStore) Init() error
- func (s *NamespaceStore) Last() Object
- func (s *NamespaceStore) Len() int
- func (s *NamespaceStore) Less(i, j int) bool
- func (s *NamespaceStore) List() (uids []string)
- func (s *NamespaceStore) Load(target any, opts ...GetOption) error
- func (i *NamespaceStore) LoadFromEnv(prefix string) error
- func (i *NamespaceStore) LoadFromFileContent(fileContent []byte, fileType string) error
- func (s *NamespaceStore) Registry(v Object)
- func (s *NamespaceStore) SetPriority(v int) *NamespaceStore
- func (s *NamespaceStore) Sort()
- func (s *NamespaceStore) Swap(i, j int)
 
- type Object
- type ObjectImpl
- type ObjectMeta
- type ObjectWrapper
- type Store
- type StoreManage
- type StoreUser
Constants ¶
      View Source
      
  
    const (
	API_NAMESPACE = "apis"
)
    
      View Source
      
  
    const (
	CONFIG_NAMESPACE = "configs"
)
    
      View Source
      
  
    const (
	CONTROLLER_NAMESPACE = "controllers"
)
    
      View Source
      
  
    const (
	DEFAULT_NAMESPACE = "default"
)
    
      View Source
      
  
const (
	DEFAULT_VERSION = "v1"
)
    Variables ¶
      View Source
      
  
var ( DefaultStore = &defaultStore{ store: []*NamespaceStore{ newNamespaceStore(CONFIG_NAMESPACE).SetPriority(99), newNamespaceStore(CONTROLLER_NAMESPACE).SetPriority(0), newNamespaceStore(DEFAULT_NAMESPACE).SetPriority(9), newNamespaceStore(API_NAMESPACE).SetPriority(-99), }, } )
Functions ¶
func ApiPathPrefix ¶ added in v2.0.6
func ConfigIocObject ¶
func ConfigIocObject(req *LoadConfigRequest) error
func DevelopmentSetup ¶
func DevelopmentSetup()
func DevelopmentSetupWithPath ¶ added in v2.0.47
func DevelopmentSetupWithPath(path string)
func GetIocObjectUid ¶
func IsFileExists ¶ added in v2.0.22
func ObjectUid ¶
func ObjectUid(o *ObjectWrapper) string
func ValidateFileType ¶
Types ¶
type InjectTag ¶
type InjectTag struct {
	// 是否自动注入
	Autowire bool
	// 空间
	Namespace string
	// 注入对象的名称
	Name string
	// 注入对象的版本, 默认v1
	Version string
}
    func NewInjectTag ¶
func NewInjectTag() *InjectTag
type LoadConfigRequest ¶
type LoadConfigRequest struct {
	// 默认加载后, 不允许重复加载, 这是为了避免多次初始化可能引发的问题
	ForceLoad bool
	// 环境变量配置
	ConfigEnv *configEnv
	// 文件配置方式
	ConfigFile *configFile
}
    func NewLoadConfigRequest ¶
func NewLoadConfigRequest() *LoadConfigRequest
type NamespaceStore ¶
type NamespaceStore struct {
	// 空间名称
	Namespace string
	// 空间优先级
	Priority int
	// 空间对象列表
	Items []*ObjectWrapper
}
    func (*NamespaceStore) ForEach ¶
func (s *NamespaceStore) ForEach(fn func(*ObjectWrapper))
func (*NamespaceStore) ImplementInterface ¶
func (s *NamespaceStore) ImplementInterface(objType reflect.Type, opts ...GetOption) (objs []Object)
寻找实现了接口的对象
func (*NamespaceStore) Init ¶
func (s *NamespaceStore) Init() error
func (*NamespaceStore) Len ¶
func (s *NamespaceStore) Len() int
func (*NamespaceStore) Less ¶
func (s *NamespaceStore) Less(i, j int) bool
func (*NamespaceStore) List ¶
func (s *NamespaceStore) List() (uids []string)
func (*NamespaceStore) Load ¶
func (s *NamespaceStore) Load(target any, opts ...GetOption) error
根据对象对象加载对象
func (*NamespaceStore) LoadFromEnv ¶
func (i *NamespaceStore) LoadFromEnv(prefix string) error
从环境变量中加载对象配置
func (*NamespaceStore) LoadFromFileContent ¶ added in v2.0.55
func (i *NamespaceStore) LoadFromFileContent(fileContent []byte, fileType string) error
func (*NamespaceStore) Registry ¶
func (s *NamespaceStore) Registry(v Object)
func (*NamespaceStore) SetPriority ¶
func (s *NamespaceStore) SetPriority(v int) *NamespaceStore
func (*NamespaceStore) Swap ¶
func (s *NamespaceStore) Swap(i, j int)
type Object ¶
type Object interface {
	// 对象初始化, 初始化对象的属性
	Init() error
	// 对象的名称, 根据名称可以从空间中取出对象
	Name() string
	// 对象版本, 默认v1
	Version() string
	// 对象优先级, 根据优先级 控制对象初始化的顺序
	Priority() int
	// 对象的销毁, 服务关闭时调用
	Close(ctx context.Context)
	// 是否允许同名对象被替换, 默认不允许被替换
	AllowOverwrite() bool
	// 对象一些元数据, 对象的更多描述信息, 扩展使用
	Meta() ObjectMeta
}
    Object接口, 需要注册到ioc空间托管的对象需要实现的方法
type ObjectImpl ¶
type ObjectImpl struct {
}
    func (*ObjectImpl) AllowOverwrite ¶
func (i *ObjectImpl) AllowOverwrite() bool
func (*ObjectImpl) Close ¶
func (i *ObjectImpl) Close(ctx context.Context)
func (*ObjectImpl) Init ¶
func (i *ObjectImpl) Init() error
func (*ObjectImpl) Meta ¶ added in v2.0.3
func (i *ObjectImpl) Meta() ObjectMeta
func (*ObjectImpl) Name ¶
func (i *ObjectImpl) Name() string
func (*ObjectImpl) Priority ¶
func (i *ObjectImpl) Priority() int
func (*ObjectImpl) Version ¶
func (i *ObjectImpl) Version() string
type ObjectMeta ¶ added in v2.0.3
func DefaultObjectMeta ¶ added in v2.0.3
func DefaultObjectMeta() ObjectMeta
type ObjectWrapper ¶
type ObjectWrapper struct {
	Name           string
	Version        string
	AllowOverwrite bool
	Priority       int
	Value          Object
}
    func NewObjectWrapper ¶
func NewObjectWrapper(obj Object) *ObjectWrapper
type Store ¶ added in v2.0.62
type Store interface {
	StoreUser
	StoreManage
}
    type StoreManage ¶
       Source Files
      ¶
      Source Files
      ¶
    
   Click to show internal directories. 
   Click to hide internal directories.