Publish Docker image (Multi-arch) / Build & push (amd64) (push) Failing after 9m20s
Release (Linux, macOS, Windows) / Linux Release (push) Failing after 55m7s
Publish Docker image (Multi-arch) / Build & push (arm64) (push) Canceled after 0s
Release (Linux, macOS, Windows) / macOS Release (push) Canceled after 0s
Release (Linux, macOS, Windows) / Windows Release (push) Canceled after 0s
Publish Docker image (Multi-arch) / Create multi-arch manifests (push) Canceled after 0s
34 lines
808 B
Go
34 lines
808 B
Go
package common
|
|
|
|
import "sync/atomic"
|
|
|
|
// PerformanceMonitorConfig 性能监控配置
|
|
type PerformanceMonitorConfig struct {
|
|
Enabled bool
|
|
CPUThreshold int
|
|
MemoryThreshold int
|
|
DiskThreshold int
|
|
}
|
|
|
|
var performanceMonitorConfig atomic.Value
|
|
|
|
func init() {
|
|
// 初始化默认配置
|
|
performanceMonitorConfig.Store(PerformanceMonitorConfig{
|
|
Enabled: true,
|
|
CPUThreshold: 90,
|
|
MemoryThreshold: 90,
|
|
DiskThreshold: 90,
|
|
})
|
|
}
|
|
|
|
// GetPerformanceMonitorConfig 获取性能监控配置
|
|
func GetPerformanceMonitorConfig() PerformanceMonitorConfig {
|
|
return performanceMonitorConfig.Load().(PerformanceMonitorConfig)
|
|
}
|
|
|
|
// SetPerformanceMonitorConfig 设置性能监控配置
|
|
func SetPerformanceMonitorConfig(config PerformanceMonitorConfig) {
|
|
performanceMonitorConfig.Store(config)
|
|
}
|