mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 15:00:27 +08:00
优化边缘节点在线状态管理
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
var sharedAPIConfig *APIConfig = nil
|
||||
var PaddingId string
|
||||
|
||||
// API节点配置
|
||||
// APIConfig API节点配置
|
||||
type APIConfig struct {
|
||||
NodeId string `yaml:"nodeId" json:"nodeId"`
|
||||
Secret string `yaml:"secret" json:"secret"`
|
||||
@@ -21,7 +21,7 @@ type APIConfig struct {
|
||||
numberId int64 // 数字ID
|
||||
}
|
||||
|
||||
// 获取共享配置
|
||||
// SharedAPIConfig 获取共享配置
|
||||
func SharedAPIConfig() (*APIConfig, error) {
|
||||
sharedLocker.Lock()
|
||||
defer sharedLocker.Unlock()
|
||||
@@ -96,18 +96,19 @@ func SharedAPIConfig() (*APIConfig, error) {
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// 设置数字ID
|
||||
// SetNumberId 设置数字ID
|
||||
func (this *APIConfig) SetNumberId(numberId int64) {
|
||||
this.numberId = numberId
|
||||
teaconst.NodeId = numberId
|
||||
PaddingId = fmt.Sprintf("%08d", numberId)
|
||||
}
|
||||
|
||||
// 获取数字ID
|
||||
// NumberId 获取数字ID
|
||||
func (this *APIConfig) NumberId() int64 {
|
||||
return this.numberId
|
||||
}
|
||||
|
||||
// 保存到文件
|
||||
// WriteFile 保存到文件
|
||||
func (this *APIConfig) WriteFile(path string) error {
|
||||
data, err := yaml.Marshal(this)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user