-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* HTTP interfaces for operations * config logger * encapsulate tasks unrelated to a protocol driver Co-authored-by: xufangyou <fangyou.xu@transwarp.io>
- Loading branch information
Showing
15 changed files
with
265 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,32 @@ | ||
package config | ||
|
||
type CommonOptions struct { | ||
type DriverOptions struct { | ||
DriverHealthCheckIntervalSecond int `json:"driver_health_check_interval_second" yaml:"driver_health_check_interval_second"` | ||
DeviceHealthCheckIntervalSecond int `json:"device_health_check_interval_second" yaml:"device_health_check_interval_second"` | ||
DeviceAutoReconnect bool `json:"device_auto_reconnect" yaml:"device_auto_reconnect"` | ||
DeviceAutoReconnect bool `json:"device_auto_reconnect" yaml:"device_auto_reconnect"` // TODO reconnect automatically by the driver framework | ||
DeviceAutoReconnectIntervalSecond int `json:"device_auto_reconnect_interval_second" yaml:"device_auto_reconnect_interval_second"` | ||
// The number of retries for automatic reconnection of the device. If it is 0, there is no limit. | ||
DeviceAutoReconnectMaxRetries int `json:"device_auto_reconnect_max_retries" yaml:"device_auto_reconnect_max_retries"` | ||
} | ||
|
||
type ManagerOptions struct { | ||
HTTP struct { | ||
Port int `json:"port" yaml:"port"` | ||
} `json:"http" yaml:"http"` | ||
} | ||
|
||
type LogOptions struct { | ||
Path string `yaml:"path" json:"path"` | ||
Level string `yaml:"level" json:"level" default:"info" validate:"regexp=^(info|debug|warn|error)$"` | ||
Format string `yaml:"format" json:"format" default:"text" validate:"regexp=^(text|json)$"` | ||
Console bool `yaml:"console" json:"console" default:"false"` | ||
Age struct { | ||
Max int `yaml:"max" json:"max" default:"15" validate:"min=1"` | ||
} `yaml:"age" json:"age"` // days | ||
Size struct { | ||
Max int `yaml:"max" json:"max" default:"50" validate:"min=1"` | ||
} `yaml:"size" json:"size"` // in MB | ||
Backup struct { | ||
Max int `yaml:"max" json:"max" default:"15" validate:"min=0"` | ||
} `yaml:"backup" json:"backup"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Manager 接口说明 | ||
|
||
基于 [go-restful-openapi](https://github.com/emicklei/go-restful-openapi) 提供了合乎 RESTful 风格的 API | ||
接口,集成 [go-swagger](https://github.com/go-swagger/go-swagger) 提供了图形化的 API 文档。 | ||
|
||
启动 Manager 后,访问 [http://172.16.251.163:10996/apidocs/#/](http://172.16.251.163:10996/apidocs/#/) 访问 Swagger 界面。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Accessor | ||
|
||
1. Accessor 功能: | ||
1. 设备数据持久化与查询; | ||
1. 流程: | ||
1. 设备元数据增加 `recording` 字段,表示是否将采集的设备进行落库; | ||
2. accessor 启动后,连接到 manager,先从 manager 获取全量设备元数据,再监听设备元数据的变更(使用 edge-device-std 定义的 operations ); | ||
3. 如果设备的 `recording` 字段为 true,则在 accessor 中启动一个 Recorder 监听 event 以及 props 对应的主题,将采集到的数据落库,否则跳过或者关闭 | ||
Recorder; | ||
2. 是否需要支持多数据源,如 InfluxDB | TDEngine 等? | ||
3. 是否可使用 ORM 框架减少开发量,如 gorm | sqlx | ent 等? | ||
4. 是否集成数据可视化工具,如 Grafana | Superset | Metabase 等? | ||
2. 是否需要支持数据推送: | ||
1. 前端通过 WebSocket 获取设备推送的数据? | ||
2. 后端直接通过 MessageBus 订阅设备对应的主题? | ||
2. 对于 [当前的架构设计](https://app.diagrams.net/#G1E_OcUtDI-vPk-1XZFqoLdzKV46zRjKUY) 来说,Manager 负责操作元数据,Accessor 负责操作设备数据。是否可以让 | ||
Manager 集成 Accessor,即 Manager 同时负责操作元数据和设备数据? | ||
3. `props *` 的设计跟 `event` 是否有重叠?或者说是否可以用 `event` 表示 `props *`? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
module github.com/thingio/edge-device-std | ||
|
||
require ( | ||
github.com/banzaicloud/logrus-runtime-formatter v0.0.0-20190729070250-5ae5475bae5e // indirect | ||
github.com/eclipse/paho.mqtt.golang v1.3.5 | ||
github.com/mitchellh/mapstructure v1.4.2 | ||
github.com/pkg/errors v0.8.1 | ||
github.com/rs/xid v1.3.0 | ||
github.com/sirupsen/logrus v1.8.1 | ||
github.com/spf13/viper v1.9.0 | ||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 | ||
) | ||
|
||
go 1.16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.