Documentation
¶
Index ¶
- type ApplicationMetrics
- type AutoRecoveryConfig
- type BinarySpec
- type CheckResult
- type ConfigSpec
- type ConfigTemplate
- type HealthCheckConfig
- type HealthStatus
- type HealthStatusDetail
- type LoggingConfig
- type MetricsConfig
- type NetworkInterface
- type OperationsConfig
- type PackageSpecV2
- type Service
- type ServiceHealth
- type ServiceMetrics
- type ServiceSpec
- type ServiceStatus
- type StartupSpec
- type SystemMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplicationMetrics ¶
type ApplicationMetrics struct {
ServiceName string
Metrics map[string]float64 // 指标名称 -> 指标值
Labels map[string]string // 指标标签
Timestamp time.Time
}
ApplicationMetrics 应用指标(业务指标)
type AutoRecoveryConfig ¶
type AutoRecoveryConfig struct {
Enabled bool
MaxRestarts int
RestartDelay time.Duration
BackoffFactor float64
MaxBackoff time.Duration
}
AutoRecoveryConfig 自动恢复配置
type CheckResult ¶
type CheckResult struct {
Healthy bool
Message string
ResponseTime time.Duration
Error error
Timestamp time.Time
}
CheckResult 健康检查结果
type ConfigSpec ¶
type ConfigSpec struct {
Format string
MainFile string
Directory string
Templates []ConfigTemplate
}
ConfigSpec 配置规格
type ConfigTemplate ¶
ConfigTemplate 配置模板
type HealthCheckConfig ¶
type HealthCheckConfig struct {
Type string // "http", "tcp", "process", "script"
Interval time.Duration
Timeout time.Duration
Retries int
HTTPPath string
HTTPMethod string
TCPPort int
ScriptPath string
}
HealthCheckConfig 健康检查配置
type HealthStatus ¶
type HealthStatus string
HealthStatus 健康状态
const ( HealthStatusUnknown HealthStatus = "unknown" HealthStatusHealthy HealthStatus = "healthy" HealthStatusUnhealthy HealthStatus = "unhealthy" HealthStatusDegraded HealthStatus = "degraded" )
type HealthStatusDetail ¶
type HealthStatusDetail struct {
Status HealthStatus
Message string
LastCheck time.Time
CheckType string
ResponseTime time.Duration
Error error
}
HealthStatusDetail 健康状态详情
type LoggingConfig ¶
LoggingConfig 日志配置
type MetricsConfig ¶
type MetricsConfig struct {
Enabled bool
Interval time.Duration
CollectSystem bool
CollectService bool
}
MetricsConfig 指标配置
type NetworkInterface ¶
NetworkInterface 网络接口信息
type OperationsConfig ¶
type OperationsConfig struct {
HealthCheck *HealthCheckConfig
AutoRecovery *AutoRecoveryConfig
Metrics *MetricsConfig
Logging *LoggingConfig
Dependencies []string
}
OperationsConfig 运维配置
type PackageSpecV2 ¶
type PackageSpecV2 struct {
Package string
Version string
Description string
Binary *BinarySpec
Startup *StartupSpec
Config *ConfigSpec
Operations *OperationsConfig `json:"operations,omitempty"`
}
PackageSpecV2 扩展的 PackageSpec,包含运维配置 这个结构体与原有的 types.PackageSpec 兼容,但添加了运维相关字段
type Service ¶
type Service struct {
ID string
Name string
Version string
Status ServiceStatus
Spec *ServiceSpec
Health *ServiceHealth
Metrics *ServiceMetrics
StartedAt *time.Time
StoppedAt *time.Time
RestartCount int
LastError error
}
Service 服务领域模型
func (*Service) UpdateStatus ¶
func (s *Service) UpdateStatus(status ServiceStatus)
UpdateStatus 更新服务状态
type ServiceHealth ¶
type ServiceHealth struct {
Status HealthStatus
LastCheck time.Time
Message string
Details []HealthStatusDetail
}
ServiceHealth 服务健康状态(用于 Service)
type ServiceMetrics ¶
type ServiceMetrics struct {
CPUUsage float64
MemoryUsage float64
MemoryBytes int64
DiskUsage float64
NetworkIn int64
NetworkOut int64
RequestCount int64
ErrorCount int64
ResponseTime time.Duration
LastUpdated time.Time
}
ServiceMetrics 服务指标
func (*ServiceMetrics) Update ¶
func (m *ServiceMetrics) Update(cpu, memory float64, memoryBytes int64)
Update 更新服务指标
type ServiceSpec ¶
type ServiceSpec struct {
Package string
Version string
Binary *BinarySpec
Startup *StartupSpec
Config *ConfigSpec
Operations *OperationsConfig
}
ServiceSpec 服务规格
type ServiceStatus ¶
type ServiceStatus string
ServiceStatus 服务状态
const ( ServiceStatusUnknown ServiceStatus = "unknown" ServiceStatusStopped ServiceStatus = "stopped" ServiceStatusStarting ServiceStatus = "starting" ServiceStatusRunning ServiceStatus = "running" ServiceStatusStopping ServiceStatus = "stopping" ServiceStatusFailed ServiceStatus = "failed" ServiceStatusRestarting ServiceStatus = "restarting" )
type StartupSpec ¶
type StartupSpec struct {
Method string // "systemd" or "direct"
ServiceName string
Args []string
Environment map[string]string
User string
Group string
}
StartupSpec 启动配置
type SystemMetrics ¶
type SystemMetrics struct {
CPUUsage float64
CPUCores int
MemoryUsage float64
MemoryTotal int64
MemoryFree int64
DiskUsage float64
DiskTotal int64
DiskFree int64
NetworkIn int64 // 已废弃,使用 NetworkInterfaces
NetworkOut int64 // 已废弃,使用 NetworkInterfaces
NetworkInterfaces []NetworkInterface
LoadAvg1 float64
LoadAvg5 float64
LoadAvg15 float64
LastUpdated time.Time
}
SystemMetrics 系统指标
Click to show internal directories.
Click to hide internal directories.