component

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Plugin

func Plugin(
	module string,
	factory Factory,
) map[string][]interface{}

func Register

func Register(name string, factory Factory) error

Types

type Component

type Component interface {
	// 获取组件实例对象
	Instance() Instance

	// 组件启动
	Start() error

	// 组件停止
	Stop() error
}

type Factory

type Factory interface {
	// 组件示例配置
	SampleConfig() string

	// 组件描述
	Description() string

	// 组件的Go Type
	ExampleType() reflect.Type

	// 创建实例
	New(config string) (Component, error)
}

func GetFactory

func GetFactory(name string) (Factory, error)

func NewFactory

func NewFactory(sampleConfig interface{}, description string, _type reflect.Type, factoryFunc FactoryFunc) Factory

func NewFactoryWithProcessor

func NewFactoryWithProcessor(sampleConfig interface{}, description string, _type reflect.Type, p Component) Factory

type FactoryFunc

type FactoryFunc func(config string) (Component, error)

type FactoryTemplate

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

func (FactoryTemplate) Description

func (f FactoryTemplate) Description() string

func (FactoryTemplate) ExampleType added in v1.0.4

func (f FactoryTemplate) ExampleType() reflect.Type

func (FactoryTemplate) New

func (f FactoryTemplate) New(config string) (Component, error)

func (FactoryTemplate) SampleConfig

func (f FactoryTemplate) SampleConfig() string

type Instance

type Instance interface {
	Name() string
	// 组件的Go Type
	Type() reflect.Type
	// 组件的Go Type
	Value() reflect.Value
	// 组件的实例
	Interface() interface{}
}

func NewInstance

func NewInstance(name string, typ reflect.Type, value reflect.Value, iface interface{}) Instance

type NamedFactory

type NamedFactory struct {
	Name    string
	Factory Factory
}

func ListFactory

func ListFactory() []NamedFactory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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