首次提交APIPark代码,面向开源

This commit is contained in:
Liujian
2024-08-12 21:38:09 +08:00
parent 7c8d175c9c
commit 469a612e41
750 changed files with 66335 additions and 0 deletions
+137
View File
@@ -0,0 +1,137 @@
package driver
import "encoding/json"
type IDriver interface {
ID() string
Name() string
Title() string
Group() string
Front() string
Define() IDefine
}
type IDefine interface {
Profession() string
Skill() string
Drivers() []*Field
Fields(fields ...*Field) []*Field
Render() map[string]interface{}
Columns() []string
}
type Driver struct {
id string
name string
title string
group string
front string
define IDefine
}
func (d *Driver) ID() string {
return d.id
}
func (d *Driver) Name() string {
return d.name
}
func (d *Driver) Title() string {
return d.title
}
func (d *Driver) Group() string {
return d.group
}
func (d *Driver) Front() string {
return d.front
}
func (d *Driver) Define() IDefine {
return d.define
}
func NewDriver(cfg *PluginCfg) IDriver {
return &Driver{
id: cfg.Id,
name: cfg.Name,
title: cfg.Cname,
group: cfg.GroupId,
front: cfg.Front,
define: NewDefine(cfg.Define),
}
}
var defaultFields = []*Field{
{
Name: "updater",
Title: "更新者",
},
{
Name: "update_time",
Title: "更新时间",
},
}
type Define struct {
profession string
skill string
drivers []*Field
fields []*Field
columns []string
render map[string]interface{}
}
func (d *Define) Columns() []string {
return d.columns
}
func NewDefine(d *PluginDefine) *Define {
columns := make([]string, 0, len(d.Fields))
for _, field := range d.Fields {
columns = append(columns, field.Name)
}
render := make(map[string]interface{})
for k, v := range d.Render {
r := make(map[string]interface{})
err := json.Unmarshal([]byte(v), &r)
if err != nil {
continue
}
render[k] = r
}
return &Define{
profession: d.Profession,
skill: d.Skill,
drivers: d.Drivers,
fields: d.Fields,
render: render,
columns: columns,
}
}
func (d *Define) Profession() string {
return d.profession
}
func (d *Define) Skill() string {
return d.skill
}
func (d *Define) Drivers() []*Field {
return d.drivers
}
func (d *Define) Fields(fields ...*Field) []*Field {
fs := make([]*Field, 0, len(d.fields)+len(fields)+len(defaultFields))
fs = append(fs, d.fields...)
fs = append(fs, fields...)
fs = append(fs, defaultFields...)
return fs
}
func (d *Define) Render() map[string]interface{} {
return d.render
}
@@ -0,0 +1,141 @@
# 文件日志
## 基本介绍
日志是用来暴露系统内部状态的一种手段,好的日志可以帮助开发人员快速定位问题所在,然后找到合适的方式解决掉问题。该插件支持将`节点访问日志`输出到`文件`中。
## 功能特性
文件日志:将请求信息输出到日志文件中,具备以下特性:
- 自定义文件的存放目录及文件名称
- 按照一定周期分割日志文件,避免单个文件过大不好查看的问题
- 定时删除过期文件,降低硬盘空间开销
可配合控制台**日志检索**插件使用,在控制台中追踪节点请求日志,并且可以下载历史日志。
## 功能演示
### 新建文件日志配置
1、点击左侧导航栏`文件日志`,进入文件日志列表页面,点击`新建文件日志`
![](http://data.eolinker.com/course/Hyej4cd6edbb5520f7f62618145d4dca056ee11ae1c3bde.png)
2、填写文件日志配置
![](http://data.eolinker.com/course/VPAFJkz46df9dbc795aeab9afe5e8d6210cca03af46b63d.png)
**配置说明**
| 字段名称 | 说明 |
| :----------- | :----------------------------------------------------------- |
| 文件名称 | 存放的文件名称,实际存放的名称会加上 `.log` 后缀,即为:{文件名称}.log |
| 存放目录 | 文件存放目录,支持相对路径和绝对路径 |
| 日志分割周期 | 按照一定周期创建新日志文件,旧日志文件将会重命名,可选项:小时、天 |
| 过期时间 | 文件保存时间,单位:天,超过保存时间的,将定时清理删除 |
| 输出格式 | 输出日志内容格式,支持单行、Json格式输出 |
| 格式化配置 | 输出格式模版,配置教程[点此](https://help.apinto.com/docs/formatter)进行跳转 |
**文件生命周期演示**
![img](http://data.eolinker.com/course/tgLQMA27ce951803c9e4c6ab3c82a899863c86f86624e01.png)
**示例格式化配置**
```
{
"fields": [
"$time_iso8601",
"$request_id",
"@request",
"@proxy",
"@response",
"@status_code",
"@time"
],
"request": [
"$request_method",
"$scheme",
"$request_uri",
"$host",
"$header",
"$remote_addr"
],
"proxy": [
"$proxy_method",
"$proxy_scheme",
"$proxy_uri",
"$proxy_host",
"$proxy_header",
"$proxy_addr"
],
"response": [
"$response_header"
],
"status_code": [
"$status",
"$proxy_status"
],
"time": [
"$request_time",
"$response_time"
]
}
```
3、点击确定后,日志输出添加完成
![img](http://data.eolinker.com/course/GXFbedia2b05c6b0ce77da8a38f536160af4ec11e1209cf.png)
### 发布到集群
1、点击列表右侧`小飞机`按钮,将日志输出配置发布上线
![img](http://data.eolinker.com/course/gxDIv7z9cc0f9e18b0e905f0e8f185a958f3c5c8d25e6a8.png)
2、选择其中需要发布上线的环境,点击`上线`
![img](http://data.eolinker.com/course/cXAzeC7c3391a55bec8eb5be6c0c6baf2baf3226d9c31e9.png)x
3、上线成功后,列表会实时显示相应集群的发布状态
![img](http://data.eolinker.com/course/n6vc56D488d01bdf61f85e12507117546806602ea0f380f.png)
### 访问接口,打印日志输出
访问在网关上上线的接口,此处使用`Apikit`的测试功能进行演示
![img](http://data.eolinker.com/course/l2sHmd3600aeebb248a48629498f4a0ab9e2529ac1e3587.png)
访问完成后,进入节点目录,查看access日志输出信息,如下图
![img](http://data.eolinker.com/course/d5ryFin9e200c902beea742b311944041249ce19732bb28.png)
## 更新日志
### V1.02023-6-19
- 插件上线
@@ -0,0 +1,229 @@
#file: noinspection YAMLSchemaValidation
id: "file-access-log.apinto.com"
name: "file-access-log"
cname: "文件日志"
resume: "将请求和响应数据输出到日志文件中"
version: "v1.0.0"
icon: "文件日志.png"
driver: "dynamic.apinto.com"
front: template/file-access-log
navigation: "navigation.system"
group_id: "log"
frontend:
- name: file-access-log
driver: apinto.intelligent.normal
router:
- path: template/file-access-log
type: normal
define: # 动态模块定义
profession: output
drivers:
- name: file
title: 文件
skill: Access-Output
fields:
- name: title # 定义从响应中对应字段中获取显示值
title: 名称
- name: id
title: ID
- name: driver
title: 驱动名称
- name: description
title: 描述
render:
file: |
{
"type":"object",
"properties":{
"scopes":{
"type":"array",
"title":"作用范围",
"x-decorator":"FormItem",
"x-component":"ArrayItems",
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"items":{
"type":"void",
"x-component":"Space",
"properties":{
"sort":{
"type":"void",
"x-decorator":"FormItem",
"x-component":"ArrayItems.SortHandle"
},
"select":{
"type":"string",
"x-decorator":"FormItem",
"x-component":"Select",
"enum":[
{
"label":"Access日志",
"value":"access_log"
}
]
},
"remove":{
"type":"void",
"x-decorator":"FormItem",
"x-component":"ArrayItems.Remove"
}
}
},
"properties":{
"add":{
"type":"void",
"title":"添加条目",
"x-component":"ArrayItems.Addition",
"x-component-props":{
"defaultValue":"access_log"
}
}
},
"name":"scopes",
"x-index":0,
"required":true
},
"file":{
"type":"string",
"title":"文件名称",
"x-decorator":"FormItem",
"x-component":"Input",
"x-validator":[
],
"x-component-props":{
},
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"name":"file",
"x-index":1,
"required":true
},
"dir":{
"type":"string",
"title":"存放目录",
"x-decorator":"FormItem",
"x-component":"Input",
"x-validator":[
],
"x-component-props":{
},
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"name":"dir",
"x-index":2,
"required":true
},
"period":{
"title":"日志分割周期",
"x-decorator":"FormItem",
"x-component":"Select",
"x-validator":[
],
"x-component-props":{
},
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"enum":[
{
"children":[
],
"label":"小时",
"value":"hour"
},
{
"children":[
],
"label":"天",
"value":"day"
}
],
"default":"hour",
"name":"period",
"x-index":3,
"required":true
},
"expore":{
"type":"number",
"title":"过期时间",
"x-decorator":"FormItem",
"x-component":"NumberPicker",
"x-validator":"integer",
"x-component-props":{
},
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"name":"expore",
"x-index":4,
"default":"3",
"description":"单位:天",
"required":true
},
"type":{
"title":"输出格式",
"x-decorator":"FormItem",
"x-component":"Select",
"x-validator":[
],
"x-component-props":{
},
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"enum":[
{
"children":[
],
"label":"单行",
"value":"line"
},
{
"children":[
],
"label":"Json",
"value":"json"
}
],
"default":"line",
"name":"type",
"x-index":5,
"required":true
},
"formatter":{
"type":"object",
"title":"格式化配置",
"x-decorator":"FormItem",
"x-component":"CustomCodeboxComponent",
"x-component-props":{
"mode":"json"
},
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

@@ -0,0 +1,103 @@
# HTTP日志
## 基本介绍
日志是用来暴露系统内部状态的一种手段,好的日志可以帮助开发人员快速定位问题所在,然后找到合适的方式解决掉问题。该插件支持将`节点访问日志`输出到**HTTP服务器**中。
## 功能特性
HTTP日志插件通过HTTP请求的方式,将节点访问日志发送给HTTP服务接口中,并且具备以下特性:
* 支持多种请求方式,包括**POST**、**PUT**、**PATCH**
* 支持自定义请求头部
* 支持日志输出格式类型
* 支持自定义日志格式化配置
## 功能演示
### 新建HTTP日志配置
1、点击左侧导航栏`系统管理` -> `HTTP日志`,进入 `HTTP日志`列表页面,点击`新建HTTP日志`
![](http://data.eolinker.com/course/RG9NpXfd8506f189f6cc37567b943aaef81fbe98094e511.png)
2、填写HTTP日志配置
![](http://data.eolinker.com/course/1Y4YJLD0edb4c6ed4fa197529245e4c841ae049e5564fb7.png)
**配置说明**
| 字段名称 | 说明 |
| :--------- | :----------------------------------------------------------- |
| 请求方式 | 请求HTTP服务接口时使用的请求方式,目前支持POST、PUT、PATCH |
| URL | HTTP服务接口的完整请求路径 |
| 请求头部 | 请求的头部信息,可以填请求HTTP服务接口时需要提供的参数,如鉴权等信息<br />填写时,需要填写JSON格式数据,数据为`key-value`格式,如:<br />`{"from":"apinto"}` |
| 输出格式 | 输出日志内容格式,支持单行、Json格式输出 |
| 格式化配置 | 输出格式模版,配置教程[点此](https://help.apinto.com/docs/formatter)进行跳转 |
**示例格式化配置**
```
{
"fields": [
"$time_iso8601",
"$request_id",
"@request",
"@proxy",
"@response",
"@status_code",
"@time"
],
"request": [
"$request_method",
"$scheme",
"$request_uri",
"$host",
"$header",
"$remote_addr"
],
"proxy": [
"$proxy_method",
"$proxy_scheme",
"$proxy_uri",
"$proxy_host",
"$proxy_header",
"$proxy_addr"
],
"response": [
"$response_header"
],
"status_code": [
"$status",
"$proxy_status"
],
"time": [
"$request_time",
"$response_time"
]
}
```
3、点击确定后,HTTP日志添加完成
![](http://data.eolinker.com/course/v3wls8u9bae38349a42610d185250ee7c2134243ccb5a40.png)
### 发布到集群
1、点击列表右侧`小飞机`按钮,将HTTP日志配置发布上线
![](http://data.eolinker.com/course/7m9Wh711763756ff29bd43ac52cc2e847de5daa33b1a848.png)
2、选择其中需要发布上线的环境,点击`上线`
![](http://data.eolinker.com/course/cJjq55Cc14c110ac9e84d9e427cf8e1af0a182689c09cd7.png)
3、上线成功后,列表会实时显示相应集群的发布状态
![](http://data.eolinker.com/course/Rh7wxRW0860282202bf48d968433581062243d8ed6b9055.png)
## 更新日志
### V1.02023-6-19
- 插件上线
@@ -0,0 +1,203 @@
id: "http-access-log.apinto.com"
name: "http-access-log"
cname: "HTTP日志"
resume: "将请求和响应日志发送到HTTP服务器"
version: "v1.0.0"
icon: "HTTP日志.png"
driver: "dynamic.apinto.com"
front: template/http-access-log
navigation: "navigation.system"
group_id: "log"
frontend:
- name: http-access-log
driver: apinto.intelligent.normal
router:
- path: template/http-access-log
type: normal
define: # 动态模块定义
profession: output
drivers:
- name: http_output
title: http请求
skill: Access-Output
fields:
- name: title # 定义从响应中对应字段中获取显示值
title: 名称
- name: id
title: ID
- name: driver
title: 驱动名称
- name: description
title: 描述
render:
http_output: |
{
"type": "object",
"properties": {
"scopes": {
"type": "array",
"title": "作用范围",
"x-decorator": "FormItem",
"x-component": "ArrayItems",
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "scopes",
"x-index": 0,
"required": true,
"items": {
"type": "void",
"x-component": "Space",
"properties": {
"sort": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.SortHandle",
"name": "sort",
"x-index": 0
},
"select": {
"type": "string",
"x-decorator": "FormItem",
"x-component": "Select",
"enum": [
{
"label": "Access日志",
"value": "access_log"
}
],
"name": "select",
"x-index": 1
},
"remove": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.Remove",
"name": "remove",
"x-index": 2
}
}
},
"properties": {
"add": {
"type": "void",
"title": "添加条目",
"x-component": "ArrayItems.Addition",
"x-component-props": {
"defaultValue": "access_log"
},
"name": "add",
"x-index": 0
}
}
},
"method": {
"type": "string",
"title": "请求方式",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"enum": [
{
"label": "POST",
"value": "POST"
},
{
"label": "PUT",
"value": "PUT"
},
{
"label": "PATCH",
"value": "PATCH"
}
],
"default": "POST",
"name": "method",
"x-index": 1,
"required": true
},
"url": {
"type": "string",
"title": "URL",
"x-decorator": "FormItem",
"x-component": "Input",
"x-validator": [
{
"triggerType": "onBlur",
"pattern": "^[a-zA-z]+://[^\\s]*$"
}
],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "url",
"x-index": 2,
"required": true
},
"headers": {
"type": "object",
"title": "请求头部",
"x-decorator": "FormItem",
"x-component": "CustomCodeboxComponent",
"x-component-props": {
"mode": "json"
},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "headers",
"x-index": 3
},
"type": {
"title": "输出格式",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"enum": [
{
"children": [],
"label": "单行",
"value": "line"
},
{
"children": [],
"label": "Json",
"value": "json"
}
],
"default": "line",
"name": "type",
"x-index": 4,
"required": true
},
"formatter": {
"type": "object",
"title": "格式化配置",
"x-decorator": "FormItem",
"x-component": "CustomCodeboxComponent",
"x-component-props": {
"mode": "json"
},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "formatter",
"x-index": 5
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -0,0 +1,107 @@
# Kafka日志
## 基本介绍
日志是用来暴露系统内部状态的一种手段,好的日志可以帮助开发人员快速定位问题所在,然后找到合适的方式解决掉问题。该插件支持将`节点访问日志`输出到`Kafka`中。
## 功能特性
Kafka日志:能够将程序运行中产生的日志内容输出到指定Kafka集群队列中。
* 支持多种请求协议,包括TCP、UDP、UNIX
* 支持设置Syslog输出日志等级
* 支持日志输出格式类型
* 支持自定义日志格式化配置
## 功能演示
### 新建Kafka日志配置
1、点击左侧导航栏`系统管理` -> `Kafka日志`,进入 `Kafka日志`列表页面,点击`新建Kafka日志`
![](http://data.eolinker.com/course/XgzgbwP536980f85f2d1367925bc1f9b7da60f1be9702c6.png)
2、填写Kafka日志配置
![](http://data.eolinker.com/course/1HAdPXZa7695b5c5b14e3755885b0586fae27235e4361cf.png)
**配置说明**
| 字段名称 | 说明 |
| :------------- | :----------------------------------------------------------- |
| 版本 | Kafka版本 |
| 服务器地址 | Kafka服务地址,多个地址用英文逗号分隔 |
| Topic | Kafka服务Topic信息 |
| Partition Type | partition的选择方式,默认采用hash,选择hash时,若partition_key为空,则采用随机选择random |
| Partition | Partition Type为manual时,该项指定分区号 |
| Partition Key | Partition Type为hash时,该项指定hash值 |
| 请求超时时间 | 超时时间,单位为second |
| 输出格式 | 输出日志内容格式,支持单行、Json格式输出 |
| 格式化配置 | 输出格式模版,配置教程[点此](https://help.apinto.com/docs/formatter)进行跳转 |
**示例格式化配置**
```
{
"fields": [
"$time_iso8601",
"$request_id",
"@request",
"@proxy",
"@response",
"@status_code",
"@time"
],
"request": [
"$request_method",
"$scheme",
"$request_uri",
"$host",
"$header",
"$remote_addr"
],
"proxy": [
"$proxy_method",
"$proxy_scheme",
"$proxy_uri",
"$proxy_host",
"$proxy_header",
"$proxy_addr"
],
"response": [
"$response_header"
],
"status_code": [
"$status",
"$proxy_status"
],
"time": [
"$request_time",
"$response_time"
]
}
```
3、点击确定后,Kafka日志添加完成
![](http://data.eolinker.com/course/v6vFVL66cf158a77aa4f483d5f76dbfb3726ca4f9971fd9.png)
### 发布到集群
1、点击列表右侧`小飞机`按钮,将Kafka日志配置发布上线
![](http://data.eolinker.com/course/JvlasZie74489a4ace107a87da0e4971df3511d41869999.png)
2、选择其中需要发布上线的环境,点击`上线`
![](http://data.eolinker.com/course/UU1UCzcb6b816a309e2bbe3a9b3428c1628abe8284daf06.png)
3、上线成功后,列表会实时显示相应集群的发布状态
![](http://data.eolinker.com/course/W9p28rR1cd161e6b9219834a45e113d75077b45a09c9cfa.png)
## 更新日志
### V1.02023-6-19
- 插件上线
@@ -0,0 +1,527 @@
id: "kafka-access-log.apinto.com"
name: "kafka-access-log"
cname: "Kafka日志"
resume: "将请求和响应日志发布到Apache Kafka topic中"
version: "v1.0.0"
icon: "Kafka日志.png"
driver: "dynamic.apinto.com"
front: template/kafka-access-log
navigation: "navigation.system"
group_id: "log"
frontend:
- name: kafka-access-log
driver: apinto.intelligent.normal
router:
- path: template/kafka-access-log
type: normal
define: # 动态模块定义
profession: output
drivers:
- name: kafka_output
title: Kafka
skill: Access-Output
fields:
- name: title # 定义从响应中对应字段中获取显示值
title: 名称
- name: id
title: ID
- name: driver
title: 驱动名称
- name: description
title: 描述
render:
kafka_output: |
{
"type": "object",
"properties": {
"scopes": {
"type": "array",
"title": "作用范围",
"x-decorator": "FormItem",
"x-component": "ArrayItems",
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "scopes",
"x-index": 0,
"required": true,
"x-designable-id": "14ambdfgkyl",
"items": {
"type": "void",
"x-component": "Space",
"x-designable-id": "5dwv836plg8",
"properties": {
"sort": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.SortHandle",
"name": "sort",
"x-index": 0,
"x-designable-id": "vj263v9oh37"
},
"select": {
"type": "string",
"x-decorator": "FormItem",
"x-component": "Select",
"enum": [
{
"label": "Access日志",
"value": "access_log"
}
],
"name": "select",
"x-index": 1,
"x-designable-id": "j2vu3wd3cu8"
},
"remove": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.Remove",
"name": "remove",
"x-index": 2,
"x-designable-id": "p4ieu9yteew"
}
}
},
"properties": {
"add": {
"type": "void",
"title": "添加条目",
"x-component": "ArrayItems.Addition",
"x-component-props": {
"defaultValue": "access_log"
},
"name": "add",
"x-index": 0,
"x-designable-id": "mfvpuzu4ma3"
}
}
},
"kafka_version": {
"title": "版本",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "kafka_version",
"default": "3.1.0",
"required": true,
"enum": [
{
"children": [],
"label": "3.1.0",
"value": "3.1.0"
},
{
"children": [],
"label": "3.0.0",
"value": "3.0.0"
},
{
"children": [],
"label": "2.8.1",
"value": "2.8.1"
},
{
"children": [],
"label": "2.8.0",
"value": "2.8.0"
},
{
"children": [],
"label": "2.7.1",
"value": "2.7.1"
},
{
"children": [],
"label": "2.7.0",
"value": "2.7.0"
},
{
"children": [],
"label": "2.6.2",
"value": "2.6.2"
},
{
"children": [],
"label": "2.6.1",
"value": "2.6.1"
},
{
"children": [],
"label": "2.6.0",
"value": "2.6.0"
},
{
"children": [],
"label": "2.5.1",
"value": "2.5.1"
},
{
"children": [],
"label": "2.5.0",
"value": "2.5.0"
},
{
"children": [],
"label": "2.4.1",
"value": "2.4.1"
},
{
"children": [],
"label": "2.4.0",
"value": "2.4.0"
},
{
"children": [],
"label": "2.3.1",
"value": "2.3.1"
},
{
"children": [],
"label": "2.3.0",
"value": "2.3.0"
},
{
"children": [],
"label": "2.2.2",
"value": "2.2.2"
},
{
"children": [],
"label": "2.2.1",
"value": "2.2.1"
},
{
"children": [],
"label": "2.2.0",
"value": "2.2.0"
},
{
"children": [],
"label": "2.1.1",
"value": "2.1.1"
},
{
"children": [],
"label": "2.1.0",
"value": "2.1.0"
},
{
"children": [],
"label": "2.0.1",
"value": "2.0.1"
},
{
"children": [],
"label": "2.0.0",
"value": "2.0.0"
},
{
"children": [],
"label": "1.1.1",
"value": "1.1.1"
},
{
"children": [],
"label": "1.1.0",
"value": "1.1.0"
},
{
"children": [],
"label": "1.0.2",
"value": "1.0.2"
},
{
"children": [],
"label": "1.0.1",
"value": "1.0.1"
},
{
"children": [],
"label": "1.0.0",
"value": "1.0.0"
},
{
"children": [],
"label": "0.11.0.2",
"value": "0.11.0.2"
},
{
"children": [],
"label": "0.11.0.1",
"value": "0.11.0.1"
},
{
"children": [],
"label": "0.11.0.0",
"value": "0.11.0.0"
},
{
"children": [],
"label": "0.10.2.2",
"value": "0.10.2.2"
},
{
"children": [],
"label": "0.10.2.1",
"value": "0.10.2.1"
},
{
"children": [],
"label": "0.10.2.0",
"value": "0.10.2.0"
},
{
"children": [],
"label": "0.10.1.1",
"value": "0.10.1.1"
},
{
"children": [],
"label": "0.10.1.0",
"value": "0.10.1.0"
},
{
"children": [],
"label": "0.10.0.1",
"value": "0.10.0.1"
},
{
"children": [],
"label": "0.10.0.0",
"value": "0.10.0.0"
},
{
"children": [],
"label": "0.9.0.1",
"value": "0.9.0.1"
},
{
"children": [],
"label": "0.9.0.0",
"value": "0.9.0.0"
},
{
"children": [],
"label": "0.8.2.2",
"value": "0.8.2.2"
},
{
"children": [],
"label": "0.8.2.1",
"value": "0.8.2.1"
},
{
"children": [],
"label": "0.8.2.0",
"value": "0.8.2.0"
}
],
"x-index": 1,
"x-designable-id": "uga7qtv47da"
},
"topic": {
"type": "string",
"title": "Topic",
"x-decorator": "FormItem",
"x-component": "Input",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "topic",
"required": true,
"x-designable-id": "27le3kmhbca",
"x-index": 2
},
"address": {
"type": "string",
"title": "服务器地址",
"x-decorator": "FormItem",
"x-component": "Input",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "address",
"x-index": 3,
"required": true,
"x-designable-id": "gz77bhn4f9d"
},
"partition_type": {
"title": "Partition Type",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"required": true,
"name": "partition_type",
"enum": [
{
"children": [],
"label": "robin",
"value": "robin"
},
{
"children": [],
"label": "hash",
"value": "warn"
},
{
"children": [],
"label": "manual",
"value": "manual"
},
{
"children": [],
"label": "random",
"value": "random"
}
],
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"x-index": 4,
"x-designable-id": "u939zlo1suv",
"default": "robin"
},
"partition": {
"type": "number",
"title": "Partition",
"x-decorator": "FormItem",
"x-component": "NumberPicker",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "partition",
"required": false,
"x-index": 5,
"x-reactions": {
"dependencies": [
"partition_type"
],
"when": "{{$deps[0] === 'manual'}}",
"fulfill": {
"state": {
"visible": true
}
},
"otherwise": {
"state": {
"visible": false
}
}
}
},
"partition_key": {
"type": "string",
"title": "Partition Key",
"x-decorator": "FormItem",
"x-component": "Input",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "partition_key",
"required": false,
"x-designable-id": "w3y6n0ali8z",
"x-index": 6,
"x-reactions": {
"dependencies": [
"partition_type"
],
"when": "{{$deps[0] === 'hash'}}",
"fulfill": {
"state": {
"visible": true
}
},
"otherwise": {
"state": {
"visible": false
}
}
}
},
"timeout": {
"type": "number",
"title": "请求超时时间",
"x-decorator": "FormItem",
"x-component": "NumberPicker",
"x-validator": [
{
"triggerType": "onInput",
"min": 0
}
],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"required": true,
"default": 10,
"name": "timeout",
"description": "单位:s,最小值:1",
"x-index": 7
},
"type": {
"title": "输出格式",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"enum": [
{
"children": [],
"label": "单行",
"value": "line"
},
{
"children": [],
"label": "Json",
"value": "json"
}
],
"default": "line",
"name": "type",
"x-index": 8,
"required": true
},
"formatter": {
"type": "object",
"title": "格式化配置",
"x-decorator": "FormItem",
"x-component": "CustomCodeboxComponent",
"x-component-props": {
"mode": "json"
},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "formatter",
"x-index": 9
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

@@ -0,0 +1,102 @@
# NSQ日志
## 基本介绍
日志是用来暴露系统内部状态的一种手段,好的日志可以帮助开发人员快速定位问题所在,然后找到合适的方式解决掉问题。该插件支持将`节点访问日志`输出到**NSQ队列**中。
## 功能特性
NSQ日志:能够将程序运行中产生的日志内容输出到指定NSQD的topic中。
* 支持填写多个nsqd请求地址
* 支持日志输出格式类型
* 支持自定义日志格式化配置
## 功能演示
### 新建NSQ日志配置
1、点击左侧导航栏`系统管理` -> `NSQ日志`,进入 `NSQ日志`列表页面,点击`新建NSQ日志`
![](http://data.eolinker.com/course/mP9cAUw2c0e57b252f4ede635f63b76ba31f5c0b826872a.png)
2、填写NSQ日志配置
![](http://data.eolinker.com/course/jzPEqMc41180eeb8d1a8cb7a9d1ff545753fb712f2df4ac.png)
**配置说明**
| 字段名称 | 说明 |
| :----------- | :----------------------------------------------------------- |
| NSQD地址列表 | NSQD提供TCP服务的地址列表,支持填写多个地址 |
| Topic | NSQD的Topic信息 |
| 鉴权Secret | 配置访问NSQD的鉴权密钥信息 |
| 输出格式 | 输出日志内容格式,支持单行、Json格式输出 |
| 格式化配置 | 输出格式模版,配置教程[点此](https://help.apinto.com/docs/formatter)进行跳转 |
**示例格式化配置**
```
{
"fields": [
"$time_iso8601",
"$request_id",
"@request",
"@proxy",
"@response",
"@status_code",
"@time"
],
"request": [
"$request_method",
"$scheme",
"$request_uri",
"$host",
"$header",
"$remote_addr"
],
"proxy": [
"$proxy_method",
"$proxy_scheme",
"$proxy_uri",
"$proxy_host",
"$proxy_header",
"$proxy_addr"
],
"response": [
"$response_header"
],
"status_code": [
"$status",
"$proxy_status"
],
"time": [
"$request_time",
"$response_time"
]
}
```
3、点击确定后,NSQ日志添加完成
![](http://data.eolinker.com/course/9bk8JLP81dd351417cf20d1cf84b8480e27056567f4f7d3.png)
### 发布到集群
1、点击列表右侧`小飞机`按钮,将NSQ日志配置发布上线
![](http://data.eolinker.com/course/7QPtDzY71d87af4a504468343eb0c80ccca823c93726a48.png)
2、选择其中需要发布上线的环境,点击`上线`
![](http://data.eolinker.com/course/AJdKFlMd13cf76912566ee666427f28e9ecfcf594a70bfc.png)
3、上线成功后,列表会实时显示相应集群的发布状态
![](http://data.eolinker.com/course/UsgdW3t020287005ddd27f229bed6532a17f2c6a8d1e9c7.png)
## 更新日志
### V1.02023-6-19
- 插件上线
@@ -0,0 +1,217 @@
id: "nsqd-access-log.apinto.com"
name: "nsqd-access-log"
cname: "NSQ日志"
resume: "将请求和响应日志发送到NSQ中"
version: "v1.0.0"
icon: "NSQ日志.png"
driver: "dynamic.apinto.com"
front: template/nsqd-access-log
navigation: "navigation.system"
group_id: "log"
frontend:
- name: nsqd-access-log
driver: apinto.intelligent.normal
router:
- path: template/nsqd-access-log
type: normal
define: # 动态模块定义
profession: output
drivers:
- name: nsqd
title: NSQD
skill: Access-Output
fields:
- name: title # 定义从响应中对应字段中获取显示值
title: 名称
- name: id
title: ID
- name: driver
title: 驱动名称
- name: description
title: 描述
render:
nsqd: |
{
"type": "object",
"properties": {
"scopes": {
"type": "array",
"title": "作用范围",
"x-decorator": "FormItem",
"x-component": "ArrayItems",
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "scopes",
"x-index": 0,
"required": true,
"items": {
"type": "void",
"x-component": "Space",
"properties": {
"sort": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.SortHandle",
"name": "sort",
"x-index": 0
},
"select": {
"type": "string",
"x-decorator": "FormItem",
"x-component": "Select",
"enum": [
{
"label": "Access日志",
"value": "access_log"
}
],
"name": "select",
"x-index": 1
},
"remove": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.Remove",
"name": "remove",
"x-index": 2
}
}
},
"properties": {
"add": {
"type": "void",
"title": "添加条目",
"x-component": "ArrayItems.Addition",
"x-component-props": {
"defaultValue": "access_log"
},
"name": "add",
"x-index": 0
}
}
},
"address": {
"type": "array",
"title": "NSQD地址列表",
"x-decorator": "FormItem",
"x-component": "ArrayItems",
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "address",
"x-index": 1,
"required": true,
"items": {
"type": "void",
"x-component": "Space",
"properties": {
"sort": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.SortHandle",
"name": "sort",
"x-index": 0
},
"input": {
"type": "string",
"x-decorator": "FormItem",
"x-component": "Input",
"name": "input",
"x-index": 1
},
"remove": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.Remove",
"name": "remove",
"x-index": 2
}
}
},
"properties": {
"add": {
"type": "void",
"title": "添加地址",
"x-component": "ArrayItems.Addition",
"name": "add",
"x-index": 0
}
}
},
"topic": {
"type": "string",
"title": "Topic",
"x-decorator": "FormItem",
"x-component": "Input",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "topic",
"x-index": 2,
"required": true
},
"auth_secret": {
"type": "string",
"title": "鉴权Secret",
"x-decorator": "FormItem",
"x-component": "Input",
"x-validator": "url",
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "auth_secret",
"x-index": 3,
"required": false
},
"type": {
"title": "输出格式",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"enum": [
{
"children": [],
"label": "单行",
"value": "line"
},
{
"children": [],
"label": "Json",
"value": "json"
}
],
"default": "line",
"name": "type",
"x-index": 4,
"required": true
},
"formatter": {
"type": "object",
"title": "格式化配置",
"x-decorator": "FormItem",
"x-component": "CustomCodeboxComponent",
"x-component-props": {
"mode": "json"
},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "formatter",
"x-index": 5
}
}
}
@@ -0,0 +1,8 @@
## 基本介绍
Redis是一个开源(BSD许可)的内存数据结构存储,用作数据库、缓存、消息代理和流媒体引擎。Redis提供数据结构,如字符串、散列、列表、集合、带范围查询的排序集合、位图、超日志、地理空间索引和流。Redis具有内置复制、Lua脚本、LRU驱逐、事务和不同级别的磁盘持久性,并通过Redis Sentinel和Redis Cluster的自动分区提供高可用性。该插件支持配置Redis Cluster信息,从而使Apinto节点接入Redis。
## 功能特性
- 配置Redis Cluster信息,帮助Apinto节点接入Redis。
- Apinto多个策略、插件依赖Redis,配置Redis后,使用Redis作为缓存数据库。
## 更新日志
### V1.02023-4-30
- 插件上线
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

@@ -0,0 +1,120 @@
id: "redis.apinto.com"
name: "redis"
cname: "Redis配置"
resume: "配置Redis Cluster信息,帮助Apinto节点接入Redis资源。"
version: "v1.0.0"
icon: "Redis配置.png"
driver: "dynamic.apinto.com"
front: template/redis
navigation: "navigation.system"
group_id: "resource"
frontend:
- name: redis
driver: apinto.intelligent.normal
router:
- path: template/redis
type: normal
define: # 动态模块定义
profession: output
drivers:
- name: redis
title: Redis
skill: Cache
fields:
- name: title # 定义从响应中对应字段中获取显示值
title: 名称
- name: id
title: ID
- name: driver
title: 驱动名称
- name: description
title: 描述
render:
redis: |
{
"type":"object",
"properties":{
"addrs":{
"type":"array",
"title":"Redis节点列表",
"x-decorator":"FormItem",
"x-component":"ArrayItems",
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"items":{
"type":"void",
"x-component":"Space",
"properties":{
"sort":{
"type":"void",
"x-decorator":"FormItem",
"x-component":"ArrayItems.SortHandle",
"x-index":0
},
"select":{
"type":"string",
"x-decorator":"FormItem",
"x-component":"Input",
"x-index":1
},
"remove":{
"type":"void",
"x-decorator":"FormItem",
"x-component":"ArrayItems.Remove",
"x-index":2
}
}
},
"properties":{
"add":{
"type":"void",
"title":"添加节点",
"x-component":"ArrayItems.Addition"
}
},
"name":"addrs",
"x-index":0,
"required":true
},
"username":{
"type":"string",
"title":"用户名",
"x-decorator":"FormItem",
"x-component":"Input",
"x-validator":[
],
"x-component-props":{
},
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"name":"username",
"x-index":1,
"required":false
},
"password":{
"type":"string",
"title":"密码",
"x-decorator":"FormItem",
"x-component":"Password",
"x-component-props":{
"checkStrength":true
},
"x-validator":[
],
"x-decorator-props":{
"labelCol":6,
"wrapperCol":10
},
"name":"password",
"x-index":2,
"required":false
}
}
}
@@ -0,0 +1,104 @@
# Syslog日志
## 基本介绍
日志是用来暴露系统内部状态的一种手段,好的日志可以帮助开发人员快速定位问题所在,然后找到合适的方式解决掉问题。该插件支持将`节点访问日志`输出到`Syslog`中。
## 功能特性
Syslog日志:能够将程序运行中产生的日志内容输出远端的Syslog服务器。
* 支持多种请求协议,包括TCP、UDP、UNIX
* 支持设置Syslog输出日志等级
* 支持日志输出格式类型
* 支持自定义日志格式化配置
## 功能演示
### 新建Syslog日志配置
1、点击左侧导航栏`系统管理` -> `Syslog日志`,进入 `Syslog日志`列表页面,点击`新建Syslog日志`
![](http://data.eolinker.com/course/JjBrSvS208f58f53d5792de7ca068c9674b97ffdaa4e3a7.png)
2、填写Syslog日志配置
![](http://data.eolinker.com/course/c456gUa9c273f26aef61fc77d0a7e7cb3513b9430b1f7f8.png)
**配置说明**
| 字段名称 | 说明 |
| :--------- | :----------------------------------------------------------- |
| 网络协议 | 请求Syslog服务的协议,支持TCP、UDP、UNIX |
| 服务器地址 | Syslog服务的地址 |
| 日志等级 | Syslog输出日志等级,支持ERROR、WARN、INFO、DEBUG、TRACE |
| 输出格式 | 输出日志内容格式,支持单行、Json格式输出 |
| 格式化配置 | 输出格式模版,配置教程[点此](https://help.apinto.com/docs/formatter)进行跳转 |
**示例格式化配置**
```
{
"fields": [
"$time_iso8601",
"$request_id",
"@request",
"@proxy",
"@response",
"@status_code",
"@time"
],
"request": [
"$request_method",
"$scheme",
"$request_uri",
"$host",
"$header",
"$remote_addr"
],
"proxy": [
"$proxy_method",
"$proxy_scheme",
"$proxy_uri",
"$proxy_host",
"$proxy_header",
"$proxy_addr"
],
"response": [
"$response_header"
],
"status_code": [
"$status",
"$proxy_status"
],
"time": [
"$request_time",
"$response_time"
]
}
```
3、点击确定后,Syslog日志添加完成
![](http://data.eolinker.com/course/igk2H3K0bfe9981f3213795e585b167da62ff91cf3d46f2.png)
### 发布到集群
1、点击列表右侧`小飞机`按钮,将Syslog日志配置发布上线
![](http://data.eolinker.com/course/SlvdD1aecbd3d4c58a5b9ec073ad15cffe23caf199d398f.png)
2、选择其中需要发布上线的环境,点击`上线`
![](http://data.eolinker.com/course/LzlDAsN472f7c71489d56f9b3a20fd0c35ff19223d7cf50.png)
3、上线成功后,列表会实时显示相应集群的发布状态
![](http://data.eolinker.com/course/NTSZ6zHc0eb936c502e19e13edb9faefb3886010e432d3d.png)
## 更新日志
### V1.02023-6-19
- 插件上线
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@@ -0,0 +1,225 @@
id: "syslog-access-log.apinto.com"
name: "syslog-access-log"
cname: "Syslog日志"
resume: "将请求和响应日志发送到Syslog中"
version: "v1.0.0"
icon: "SYSLOG日志.png"
driver: "dynamic.apinto.com"
front: template/syslog-access-log
navigation: "navigation.system"
group_id: "log"
frontend:
- name: syslog-access-log
driver: apinto.intelligent.normal
router:
- path: template/syslog-access-log
type: normal
define: # 动态模块定义
profession: output
drivers:
- name: syslog_output
title: Syslog
skill: Access-Output
fields:
- name: title # 定义从响应中对应字段中获取显示值
title: 名称
- name: id
title: ID
- name: driver
title: 驱动名称
- name: description
title: 描述
render:
syslog_output: |
{
"type": "object",
"properties": {
"scopes": {
"type": "array",
"title": "作用范围",
"x-decorator": "FormItem",
"x-component": "ArrayItems",
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "scopes",
"x-index": 0,
"required": true,
"items": {
"type": "void",
"x-component": "Space",
"properties": {
"sort": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.SortHandle",
"name": "sort",
"x-index": 0
},
"select": {
"type": "string",
"x-decorator": "FormItem",
"x-component": "Select",
"enum": [
{
"label": "Access日志",
"value": "access_log"
}
],
"name": "select",
"x-index": 1
},
"remove": {
"type": "void",
"x-decorator": "FormItem",
"x-component": "ArrayItems.Remove",
"name": "remove",
"x-index": 2
}
}
},
"properties": {
"add": {
"type": "void",
"title": "添加条目",
"x-component": "ArrayItems.Addition",
"x-component-props": {
"defaultValue": "access_log"
},
"name": "add",
"x-index": 0
}
}
},
"network": {
"title": "网络协议",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "network",
"required": true,
"enum": [
{
"children": [],
"label": "TCP",
"value": "tcp"
},
{
"children": [],
"label": "UDP",
"value": "udp"
},
{
"children": [],
"label": "UNIX",
"value": "unix"
}
],
"x-index": 1
},
"address": {
"type": "string",
"title": "服务器地址",
"x-decorator": "FormItem",
"x-component": "Input",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "address",
"x-index": 2,
"required": true
},
"level": {
"title": "日志等级",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"required": true,
"name": "level",
"enum": [
{
"children": [],
"label": "ERROR",
"value": "error"
},
{
"children": [],
"label": "WARN",
"value": "warn"
},
{
"children": [],
"label": "INFO",
"value": "info"
},
{
"children": [],
"label": "DEBUG",
"value": "debug"
},
{
"children": [],
"label": "TRACE",
"value": "trace"
}
],
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"x-index": 3
},
"type": {
"title": "输出格式",
"x-decorator": "FormItem",
"x-component": "Select",
"x-validator": [],
"x-component-props": {},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"enum": [
{
"children": [],
"label": "单行",
"value": "line"
},
{
"children": [],
"label": "Json",
"value": "json"
}
],
"default": "line",
"name": "type",
"x-index": 4,
"required": true
},
"formatter": {
"type": "object",
"title": "格式化配置",
"x-decorator": "FormItem",
"x-component": "CustomCodeboxComponent",
"x-component-props": {
"mode": "json"
},
"x-decorator-props": {
"labelCol": 6,
"wrapperCol": 10
},
"name": "formatter",
"x-index": 5
}
}
}
+1
View File
@@ -0,0 +1 @@
package driver
+47
View File
@@ -0,0 +1,47 @@
package driver
import (
"embed"
"path"
"github.com/eolinker/eosc/log"
)
var (
//go:embed embed
pluginDir embed.FS
)
func init() {
err := LoadPlugins(&pluginDir, "embed", "plugin.yml")
if err != nil {
panic(err)
}
}
func LoadPlugins(fs *embed.FS, dir string, target string) error {
entries, err := fs.ReadDir(dir)
if err != nil {
return err
}
for _, e := range entries {
if !e.IsDir() {
continue
}
filePath := path.Join(dir, e.Name(), target)
fileContent, err := fs.ReadFile(filePath)
if err != nil {
return err
}
pluginCfg, err := Read(fileContent)
if err != nil {
log.Errorf("read inert plugin file(%s) error: %v", filePath, err)
return err
}
Register(NewDriver(pluginCfg))
}
return err
}
+80
View File
@@ -0,0 +1,80 @@
package driver
import "github.com/eolinker/eosc"
var (
manager = NewManager()
)
func NewManager() *Manager {
return &Manager{
drivers: eosc.BuildUntyped[string, IDriver](),
driversByGroup: eosc.BuildUntyped[string, DynamicDrivers](),
}
}
type DynamicDrivers eosc.Untyped[string, IDriver]
type Manager struct {
drivers DynamicDrivers
driversByGroup eosc.Untyped[string, DynamicDrivers]
}
func (m *Manager) Register(driver IDriver) {
m.drivers.Set(driver.Name(), driver)
if drivers, ok := m.driversByGroup.Get(driver.Group()); ok {
drivers.Set(driver.Name(), driver)
} else {
drivers = eosc.BuildUntyped[string, IDriver]()
drivers.Set(driver.Name(), driver)
m.driversByGroup.Set(driver.Group(), drivers)
}
}
func (m *Manager) Get(name string) (IDriver, bool) {
return m.drivers.Get(name)
}
func (m *Manager) List() []IDriver {
return m.drivers.List()
}
func (m *Manager) ListByGroup(group string) []IDriver {
if drivers, ok := m.driversByGroup.Get(group); ok {
return drivers.List()
}
return nil
}
func (m *Manager) Drivers() []string {
return m.drivers.Keys()
}
func (m *Manager) DriversByGroup(group string) []string {
if drivers, ok := m.driversByGroup.Get(group); ok {
return drivers.Keys()
}
return nil
}
func Register(driver IDriver) {
manager.Register(driver)
}
func Get(name string) (IDriver, bool) {
return manager.Get(name)
}
func Drivers(group ...string) []string {
if len(group) > 0 && group[0] != "" {
return manager.DriversByGroup(group[0])
}
return manager.Drivers()
}
func List(group ...string) []IDriver {
if len(group) > 0 && group[0] != "" {
return manager.ListByGroup(group[0])
}
return manager.List()
}
+29
View File
@@ -0,0 +1,29 @@
package driver
type PluginCfg struct {
Id string `json:"id,omitempty" yaml:"id"`
Name string `json:"name,omitempty" yaml:"name"`
Cname string `json:"cname,omitempty" yaml:"cname"`
Resume string `json:"resume,omitempty" yaml:"resume"`
Version string `json:"version,omitempty" yaml:"version"`
ICon string `json:"icon,omitempty" yaml:"icon"`
Driver string `json:"driver,omitempty" yaml:"driver"`
GroupId string `json:"group_id,omitempty" yaml:"group_id"`
Front string `json:"front,omitempty" yaml:"front"`
Define *PluginDefine `json:"define,omitempty" yaml:"define"`
}
type PluginDefine struct {
Profession string `yaml:"profession"`
Drivers []*Field `yaml:"drivers"`
Skill string `yaml:"skill"`
Fields []*Field `yaml:"fields"`
Render map[string]string `yaml:"render"`
}
type Field struct {
Name string `yaml:"name"`
Title string `yaml:"title"`
Attr string `json:"attr,omitempty"`
Enum []string `json:"enum,omitempty"`
}
+24
View File
@@ -0,0 +1,24 @@
package driver
import (
"gopkg.in/yaml.v3"
)
func Read(input []byte) (*PluginCfg, error) {
p := new(PluginCfg)
err := yaml.Unmarshal(input, &p)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(input, p)
if err != nil {
return nil, err
}
if p.Version == "" {
p.Version = "v0.0.0"
}
return p, nil
}