feat(logic): 优化数据采集器启动流程并增加节点状态管理功能
- 移除配置参数依赖,改为直接调用Boot()函数 - 添加主机名自动获取和设置功能 - 新增SaveNodeStatus函数用于保存节点状态数据 - 在数据变化时同时保存节点状态信息 - 创建CollectorNode数据库模型用于存储节点状态
This commit is contained in:
28
internal/models/collect_node.go
Normal file
28
internal/models/collect_node.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
)
|
||||
|
||||
// CollectorNode 节点状态数据库模型
|
||||
type CollectorNode struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;comment:主键ID"`
|
||||
ConfigKey string `json:"config_key" gorm:"type:varchar(100);not null;uniqueIndex;comment:配置键"`
|
||||
HomeName string `json:"home_name" gorm:"type:varchar(100);not null;comment:主机名称"`
|
||||
ProjectRoot string `json:"project_root" gorm:"type:varchar(500);not null;comment:项目根目录"`
|
||||
QmtStatus string `json:"qmt_status" gorm:"type:varchar(50);not null;comment:QMT连接状态"`
|
||||
StartTime int64 `json:"start_time" gorm:"not null;comment:启动时间戳(纳秒)"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime;comment:记录更新时间"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;comment:记录创建时间"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
database.AppendMigrate(&CollectorNode{})
|
||||
}
|
||||
|
||||
// TableName 设置表名
|
||||
func (CollectorNode) TableName() string {
|
||||
return "collector_node"
|
||||
}
|
||||
Reference in New Issue
Block a user