Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Binary 二进制文件 Binary ResourceType = "binary" // Image 图片 Image = "image" // Audio 音频 Audio = "audio" // Video 视频 Video = "video" )
View Source
const PluginConfigRelativePath = "./plugin.json"
PluginConfigRelativePath PluginProperty 对应的配置文件在插件包中的相对路径 相对于插件包内部的根目录
View Source
const RequireConfigRelativePath = "./require.json"
RequireConfigRelativePath Require 对应的配置文件在插件包中的相对路径 相对于插件包内部的根目录
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dependency ¶
type Dependency struct {
// 插件名
Name string `json:"name" yaml:"name" xml:"name"`
// 分组名
Group string `json:"group" yaml:"group" xml:"group"`
// 版本约束
Version VersionConstraints `json:"version" yaml:"version" xml:"version"`
// 仓库地址
Repository string `json:"repository" yaml:"repository" xml:"repository"`
}
Dependency 依赖
type Loader ¶
type Loader interface {
// SetPluginRootPath 设置插件包存放的根路径
// path 插件包存放的根路径,必须是绝对路径
SetPluginRootPath(path string)
// RegisterReaderFactory 注册一个插件包解析器工厂
RegisterReaderFactory(factory ParserFactory)
// GetAllComponents 获取所有组件
GetAllComponents() (*core.ComponentPool, error)
// Destroy 销毁插件加载器
// 插件加载器应该维护注册到它内部的「插件包解析器工厂」的销毁
Destroy() error
}
Loader 插件加载器
type Parser ¶
type Parser interface {
// ParseType 获取该插件包解析器的解析类型
ParseType() ParseType
// Read 读取指定文件的内容
// path 相对于插件包内部的根目录的路径
Read(path string) ([]byte, error)
// GetRequire 获取该解析器对应的插件的 Require 配置
GetRequire() (*Require, error)
// GetProperty 获取该解析器对应的插件的 PluginProperty 配置
GetProperty() (*PluginProperty, error)
// GetComponent 获取组件
// path 相对于插件包内部的根目录的路径
GetComponent(path string) (core.Component, error)
// GetComponents 获取组件
GetComponents() (*core.ComponentPool, error)
// Close 关闭读取器
Close() error
}
Parser 插件包解析器
type ParserFactory ¶
type ParserFactory interface {
// Supported 返回该插件包工厂支持的插件包解析类型
Supported() []ParseType
// GetParser 获取插件包解析器
// path 插件包的绝对路径
GetParser(path string) (Parser, error)
// Destroy 销毁插件包解析器工厂
// 插件包解析器工厂应该维护其内部的「插件解析器」的关闭
Destroy() error
}
ParserFactory 插件包解析器工厂 插件包解析器需要负责构建解析器缓存,减少重复构建解析器带来的消耗
type PluginProperty ¶
type PluginProperty struct {
// 插件名
Name string `json:"name" yaml:"name" xml:"name"`
// 分组名
Group string `json:"group" yaml:"group" xml:"group"`
// 插件描述
Desc map[string]string `json:"desc" yaml:"desc" xml:"desc"`
// 版本
Version core.Version `json:"version" yaml:"version" xml:"version"`
// 显示名
DisplayName map[string]string `json:"display-name" yaml:"display-name" xml:"display-name"`
// 仓库地址
Repository string `json:"repository" yaml:"repository" xml:"repository"`
// 程序
Programs []Program `json:"programs" yaml:"programs" xml:"programs"`
// 资源文件
Resources []Resource `json:"resources" yaml:"resources" xml:"resources"`
// 依赖
Dependencies []Dependency `json:"dependencies" yaml:"dependencies" xml:"dependencies"`
}
PluginProperty 插件属性
type Program ¶
type Program struct {
// 插件类型
Type ProgramType `json:"type" yaml:"type" xml:"type"`
// 程序语言
Language string `json:"language" yaml:"language" xml:"language"`
// 程序路径
// 相对于程序包的路径
Path string `json:"path" yaml:"path" xml:"path"`
// 加载名称
// 被加载的变量在类库中的全局变量名
LoadName string `json:"load-name" yaml:"load-name" xml:"load-name"`
}
Program 程序
type ProgramType ¶
type ProgramType string
ProgramType 程序类型
const ( // Library 类库 Library ProgramType = "lib" )
type Require ¶
type Require struct {
// 核心库版本号
Core core.Version `json:"core" yaml:"core" xml:"core"`
// 插件规范版本号
Plugin core.Version `json:"plugin" yaml:"plugin" xml:"plugin"`
}
Require 插件包要求规范
type Resource ¶
type Resource struct {
// 资源类型
Type ResourceType `json:"type" yaml:"type" xml:"type"`
// 资源路径
// 相对于程序包的路径
Path string `json:"path" yaml:"path" xml:"path"`
// 映射路径
// 映射到 core.Config 中的配置路径
Mapping string `json:"mapping" yaml:"mapping" xml:"mapping"`
}
Resource 资源
Click to show internal directories.
Click to hide internal directories.