domain

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

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 BinarySpec

type BinarySpec struct {
	Name string
	Path string
}

BinarySpec 二进制文件规格

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

type ConfigTemplate struct {
	Source      string
	Destination string
}

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

type LoggingConfig struct {
	Directory string
	MaxSize   int64
	MaxFiles  int
	Level     string
}

LoggingConfig 日志配置

type MetricsConfig

type MetricsConfig struct {
	Enabled        bool
	Interval       time.Duration
	CollectSystem  bool
	CollectService bool
}

MetricsConfig 指标配置

type NetworkInterface

type NetworkInterface struct {
	Name    string
	RxBytes int64
	TxBytes int64
}

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) IsHealthy

func (s *Service) IsHealthy() bool

IsHealthy 检查服务是否健康

func (*Service) IsRunning

func (s *Service) IsRunning() bool

IsRunning 检查服务是否运行中

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)

func (*ServiceHealth) IsHealthy

func (h *ServiceHealth) IsHealthy() bool

IsHealthy 检查是否健康

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) Reset

func (m *ServiceMetrics) Reset()

Reset 重置指标

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 系统指标

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL