system

package
v0.0.0-...-082c65a Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SystemStateInitialized = "initialized"
	SystemStateRunning     = "running"
	SystemStateStopping    = "stopping"
	SystemStateStopped     = "stopped"
	SystemStateError       = "error"
)

添加系统状态常量

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskStats

type DiskStats struct {
	BytesRead    uint64
	BytesWritten uint64
	Operations   int64
}

type HealthCheck

type HealthCheck struct {
	Name     string
	Check    func() error
	Interval time.Duration
	Timeout  time.Duration
	Required bool
}

添加健康检查

type NetworkStats

type NetworkStats struct {
	BytesRead    uint64
	BytesWritten uint64
	Connections  int
}

type System

type System struct {
	// contains filtered or unexported fields
}

System DaoFlow系统主结构

func NewSystem

func NewSystem(opts SystemOptions) (*System, error)

NewSystem 创建新的DaoFlow系统

func (*System) EmitEvent

func (s *System) EmitEvent(evt SystemEvent)

func (*System) GetStatus

func (s *System) GetStatus() types.SystemStatus

GetStatus 获取系统状态

func (*System) Initialize

func (s *System) Initialize(ctx context.Context) error

添加系统生命周期方法

func (*System) Shutdown

func (s *System) Shutdown(ctx context.Context) error

func (*System) Start

func (s *System) Start() error

Start 启动系统

func (*System) Stop

func (s *System) Stop() error

Stop 停止系统

func (*System) UpdateConfig

func (s *System) UpdateConfig(newConfig SystemConfig) error

func (*System) UpdateMetrics

func (s *System) UpdateMetrics()

UpdateMetrics 更新系统指标

type SystemConfig

type SystemConfig struct {
	Basic     BasicConfig
	Meta      MetaConfig
	Evolution EvolutionConfig
	Control   ControlConfig
	Monitor   MonitorConfig
	Resources ResourceConfig
}

添加动态配置支持

type SystemEvent

type SystemEvent struct {
	Type      string
	Source    string
	Timestamp time.Time
	Data      map[string]interface{}
}

添加事件系统

type SystemMetrics

type SystemMetrics struct {
	Uptime         time.Duration // 运行时间
	MemoryUsage    uint64        // 内存使用
	CPUUsage       float64       // CPU使用率
	GoroutineCount int           // 协程数量
	ErrorCount     int64         // 错误计数
	EventCount     int64         // 事件计数

	// 新增指标
	HeapObjects uint64        // 堆对象数
	HeapAlloc   uint64        // 堆分配量
	GCPause     time.Duration // GC暂停时间
	ThreadCount int           // 线程数
	MutexWait   int64         // 互斥锁等待次数
	NetworkIO   NetworkStats  // 网络IO统计
	DiskIO      DiskStats     // 磁盘IO统计
}

SystemMetrics 系统指标

type SystemOptions

type SystemOptions struct {
	Name       string // 系统名称
	Version    string // 系统版本
	ConfigPath string // 配置路径
}

SystemOptions 系统配置选项

type SystemResources

type SystemResources struct {
	CPU     *CPUResource
	Memory  *MemoryResource
	Network *NetworkResource
	Disk    *DiskResource
}

添加资源管理

Directories

Path Synopsis
control
evolution
meta
monitor

Jump to

Keyboard shortcuts

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