Documentation
¶
Index ¶
- Constants
- Variables
- func GetCpuTime() (*cpu.TimesStat, error)
- func GetDateTime() (localTime string, utcTime string, unixTime int64)
- func GetEnv(key string, dfault string, combineWith ...string) string
- func HashRawConfig(config *common.Config) (error, string)
- func IsInDocker() bool
- func Md5(str string) string
- func SetResourceLimit(maxCpuLimit, checkTimes int)
- type CPULimit
Constants ¶
View Source
const (
MaxCheckTimes = 10
)
Variables ¶
View Source
var ( IsEnableRateLimiter bool // 是否开启速率限制 GlobalCpuLimiter *CPULimit // CPU使用率限制 )
View Source
var ClockTicks = 100 // default value
Functions ¶
func GetCpuTime ¶
GetCpuTime copy from github.com/shirou/[email protected]+incompatible/process/process_linux.go
func GetDateTime ¶
GetDateTime 获取系统当前时间
func GetEnv ¶
GetEnv retrieves the environment variable key. If it does not exist it returns the default. github.com/shirou/[email protected]+incompatible/internal/common/common.go
func HashRawConfig ¶
HashRawConfig 获取配置hash值
func IsInDocker ¶
func IsInDocker() bool
当且仅当 /.dockerenv 的前提下 文件存在且 cgroup 权限为 ro 或者 /proc/1/sched 进程号不为 1
func SetResourceLimit ¶
func SetResourceLimit(maxCpuLimit, checkTimes int)
SetResourceLimit : 在一定程度上限制CPU使用 maxCpuLimit: 最大CPU使用率限制 checkTimes: 资源限制的检查次数
Types ¶
type CPULimit ¶
type CPULimit struct {
// contains filtered or unexported fields
}
CPULimit cpu limit object
func (*CPULimit) GetCheckInterval ¶
GetCheckInterval : get cpu check interval
func (*CPULimit) GetCpuTimes ¶
GetCpuTimes 获取指定进程的CPU时间统计信息。 p: 指向 process.Process 的指针,代表要查询的进程。 返回值:
*cpu.TimesStat: 指向 cpu.TimesStat 的指针,包含CPU时间统计信息。 error: 如果发生错误,将返回相应的错误信息。
Click to show internal directories.
Click to hide internal directories.