Documentation
¶
Index ¶
- func ConvertInput(input interface{}, data interface{}) (interface{}, error)
- func ConvertValue(v interface{}, dst interface{}) error
- func RegisterDriver(driver DriverInterface)
- func UUID() string
- type Action
- type ActionDescriptor
- type Driver
- func (d *Driver) ActionHandler(ctx *bee.Context)
- func (d *Driver) Description() string
- func (d *Driver) ExecAction(a *Action) (Output, error)
- func (d *Driver) LogErrorf(format string, args ...interface{})
- func (d *Driver) LogFatal(args ...interface{})
- func (d *Driver) Logf(format string, args ...interface{})
- func (d *Driver) Logln(args ...interface{})
- func (d *Driver) Namespace() string
- func (d *Driver) NewAction(actionNamespace string, values Values) (*Action, error)
- func (d *Driver) Options() Options
- func (d *Driver) String() string
- func (d *Driver) Title() string
- type DriverConfig
- type DriverFactory
- type DriverFactoryInterface
- type DriverInterface
- type InputDescriptor
- type NotFoundItemError
- type Option
- type OptionDescriptor
- type Options
- type Output
- type OutputDescriptor
- type OutputType
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertInput ¶
func ConvertInput(input interface{}, data interface{}) (interface{}, error)
ConvertInput 解析Input输入
func ConvertValue ¶
func ConvertValue(v interface{}, dst interface{}) error
ConvertValue 尝试将 v 转换为 dst
func RegisterDriver ¶
func RegisterDriver(driver DriverInterface)
RegisterDriver 将驱动器注册到全局中, 注册时需保证Namespace唯一。
Types ¶
type Action ¶
type Action struct {
ID string `json:"id"`
Title string `json:"title"`
Driver string `json:"driver"` //对应Driver的Namespace
Namespace string `json:"namespace"`
Input Values `json:"inputValues"`
}
Action 驱动动作
type ActionDescriptor ¶
type ActionDescriptor struct {
Title string `json:"title"`
Namespace string `json:"namespace"`
Description string `json:"desc"`
Input []InputDescriptor `json:"input"`
Output []OutputDescriptor `json:"output"`
}
ActionDescriptor Action描述信息
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver 驱动
func (*Driver) ActionHandler ¶
ActionHandler 执行Action
func (*Driver) ExecAction ¶
ExecAction 执行Action,但基础Driver中不具体实现。
func (*Driver) LogFatal ¶
func (d *Driver) LogFatal(args ...interface{})
LogFatal logs a fatal error
type DriverConfig ¶
type DriverConfig struct {
Title string `json:"title"` //驱动名称,简称
Namespace string `json:"namespace"` //驱动标识符,必须全局唯一。依次同其他驱动器进行区分
Description string `json:"desc"` //驱动描述,在使用驱动时,可以显示对驱动的描述,以方便了解驱动功能
Options Options `json:"options"` //驱动器配置信息
}
DriverConfig 驱动器配置
type DriverFactoryInterface ¶
type DriverFactoryInterface interface {
// 驱动ID
ID() string
// 驱动名称
Name() string
// 驱动描述
Description() string
// 创建驱动所需的选项配置信息
Options() []OptionDescriptor
// 驱动所还有的行为描述
Actions() []ActionDescriptor
// New 新建驱动实例
New(name, description string, options Options) DriverInterface
}
DriverFactoryInterface 用于创建驱动器.
type DriverInterface ¶
type DriverInterface interface {
// Title 此驱动名称
Title() string
// Namespace 驱动标识符
Namespace() string
// 驱动器描述
Description() string
// 获取驱动器配置选项信息
Options() Options
Logln(args ...interface{})
Logf(format string, args ...interface{})
LogErrorf(format string, args ...interface{})
LogFatal(args ...interface{})
// Actions 行为描述
Actions() []ActionDescriptor
NewAction(actionNamespace string, input Values) (*Action, error)
// Action 执行行为命令
ExecAction(action *Action) (interface{}, error)
String() string
}
DriverInterface 驱动器接口
type InputDescriptor ¶
type InputDescriptor struct {
OptionDescriptor
Required bool `json:"required"` //是否是必要参数
}
InputDescriptor 输入信息描述
type NotFoundItemError ¶
type NotFoundItemError struct {
Item string
}
NotFoundItemError 不存在该项Error
func (*NotFoundItemError) Error ¶
func (n *NotFoundItemError) Error() string
type Option ¶
type Option struct {
Name string `json:"name"` //参数名称
Desc OptionDescriptor `json:"desc"` //参数描述
Value interface{} `json:"value"`
}
Option 选项信息
type OptionDescriptor ¶
type OptionDescriptor struct {
Name string `json:"name"` //参数名称
Description string `json:"desc"` //参数描述
ValueType kind.Kind `json:"valueType"` //参数值数据类型
}
OptionDescriptor Option描述
type Options ¶
type Options []Option
Options 一组选项信息
type Output ¶
type Output struct {
ID string `json:"id"`
ActionID string `json:"action_id"`
Type OutputType `json:"typ"`
Value interface{} `json:"value"`
}
Output 输出信息
Click to show internal directories.
Click to hide internal directories.