Documentation
¶
Overview ¶
Package resources provides resource limit management for the application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRlimits ¶
GetRlimits returns current rlimit values.
Types ¶
type Config ¶
type Config struct {
// MaxMemoryMB is the maximum memory in megabytes (0 = no limit).
MaxMemoryMB int64 `yaml:"max_memory_mb" yaml:"max_memory_mb"`
// MaxCPUPercent is the maximum CPU percentage (0 = no limit).
MaxCPUPercent int `yaml:"max_cpu_percent" yaml:"max_cpu_percent"`
// MaxOpenFiles is the maximum number of open files.
MaxOpenFiles uint64 `yaml:"max_open_files" yaml:"max_open_files"`
// MaxGoroutines is the maximum number of goroutines (0 = no limit).
MaxGoroutines int `yaml:"max_goroutines" yaml:"max_goroutines"`
// GCPercent is the garbage collection target percentage.
GCPercent int `yaml:"gc_percent" yaml:"gc_percent"`
}
Config holds resource limit configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default resource configuration.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter manages resource limits for the application.
func NewLimiter ¶
NewLimiter creates a new resource limiter.
func (*Limiter) CheckGoroutineLimit ¶
CheckGoroutineLimit checks if the goroutine limit has been exceeded.
func (*Limiter) Stats ¶
func (l *Limiter) Stats() ResourceStats
Stats returns current resource usage statistics.
type ResourceStats ¶
type ResourceStats struct {
AllocMB int64 `json:"alloc_mb"`
TotalAllocMB int64 `json:"total_alloc_mb"`
SysMB int64 `json:"sys_mb"`
NumGoroutines int `json:"num_goroutines"`
NumCPU int `json:"num_cpu"`
GOMAXPROCS int `json:"gomaxprocs"`
NumGC uint32 `json:"num_gc"`
GCPauseNs uint64 `json:"gc_pause_ns"`
}
ResourceStats holds current resource usage statistics.
Click to show internal directories.
Click to hide internal directories.