resource

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "resource"

Variables

This section is empty.

Functions

func GetAllKind

func GetAllKind() []string

GetAllKind 获取所有的资源类型

func GetByKind

func GetByKind(kind string) map[string]Resource

GetByKind 通过资源类型获取资源列表

func GetResId added in v0.1.26

func GetResId(m map[string]interface{}) string

func Has

func Has(kind string, name string) bool

Has 检查资源是否存在

func Remove

func Remove(kind string, name string)

Remove 删除资源

Types

type Builder added in v0.1.26

type Builder interface {
	Build() io.Closer
}

type BuilderFactory added in v0.1.26

type BuilderFactory interface {
	Builder() Builder
	Update(name, kind string, builder Builder)
	IsValid() bool
	Wrapper(res Resource) Resource
	Di(kind string) func(obj inject.Object, field inject.Field) (interface{}, bool)
}

type Factory added in v0.1.26

type Factory struct {
	DefaultCfg Builder                                                         `json:"-" yaml:"-" inject:"required"`
	ResType    Resource                                                        `json:"-" yaml:"-"`
	OnDi       func(obj inject.Object, field inject.Field) (interface{}, bool) `json:"-" yaml:"-"`
}

func (Factory) Builder added in v0.1.26

func (f Factory) Builder() Builder

func (Factory) Di added in v0.1.26

func (f Factory) Di(kind string) func(obj inject.Object, field inject.Field) (interface{}, bool)

func (Factory) IsValid added in v0.1.26

func (f Factory) IsValid() bool

func (Factory) Update added in v0.1.26

func (f Factory) Update(name, kind string, builder Builder)

func (Factory) Wrapper added in v0.1.26

func (f Factory) Wrapper(res Resource) Resource

type Resource

type Resource interface {
	// Kind 资源类型
	Kind() string

	// Name 资源名字(ID)
	Name() string

	// GetRes 获取真实的资源对象
	// 用完对象后记得release, 不然会死锁
	GetRes() interface{}

	// Done 资源释放
	Done()

	Log() *zap.Logger
}

Resource 资源对象接口

Resource 是真实对象的wrapper, 可以通过getObj获取真实的内部对象

func Get

func Get(kind string, name string) Resource

Get 根据类型和名字获取一个资源

func GetOne

func GetOne(kind string) Resource

GetOne 根据类型获取一个资源

Jump to

Keyboard shortcuts

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