runtimeKit

package
v2.1.31 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package runtimeKit 主要是对如下包的封装:"runtime"

Index

Constants

This section is empty.

Variables

View Source
var GetHostInfo func() (*host.InfoStat, error) = host.Info
View Source
var GoRoot string

GoRoot GOROOT环境变量

View Source
var GoVersion string

GoVersion Golang的版本号

View Source
var PID int = os.Getpid()

PID 当前进程的id.

Functions

func GetAvailableMemoryPercent

func GetAvailableMemoryPercent() (float64, error)

GetAvailableMemoryPercent

@return e.g. (49.09634590148926, nil)

func GetAvailableMemoryRatio

func GetAvailableMemoryRatio() (float64, error)

GetAvailableMemoryRatio 获取可用内存的比例

@return e.g. (0.4909677505493164, nil)

“比例”和“比率”的区别? 全班人数50人,男生30,女生20,那男生的比例就是30/50,同理女生的就是20/50,那么男女的比率是什么呢,是30/20。

func GetDockerIdList

func GetDockerIdList() ([]string, error)

GetDockerIdList

通过第三方库 gopsutil 实现.

func GetMacAddresses

func GetMacAddresses() ([]string, error)

GetMacAddresses *

func GetUsedMemoryPercent

func GetUsedMemoryPercent() (float64, error)

GetUsedMemoryPercent

@return e.g. (50.903940200805664, nil)

func GetUsedMemoryRatio

func GetUsedMemoryRatio() (float64, error)

GetUsedMemoryRatio

@return e.g. (0.509037971496582, nil)

func PidExists

func PidExists(pid int32) (bool, error)

PidExists 判断 传参pid 对应的进程是否存在

PS: 通过 第三方库gopsutil 实现.

e.g. (-1) => (false, error(invalid pid -1)) (13120) => (true, nil) (13121) => (false, nil)

func SetSoftMemoryLimit

func SetSoftMemoryLimit(limit int64) (int64, error)

SetSoftMemoryLimit 软内存限制(soft memory limit)

PS: (1) This limit will be respected even if GOGC=off (or, if SetGCPercent(-1) is executed). (2) 默认memory limit是math.MaxInt64(即第一次调用debug.SetMemoryLimit()的返回值为math.MaxInt64).

@param limit 单位: B(byte;字节) @return 之前的内存限制

Types

type MemoryStat

type MemoryStat mem.VirtualMemoryStat

MemoryStat Total = Available + Used

func GetMemoryStat

func GetMemoryStat() (*MemoryStat, error)

GetMemoryStat 获取当前瞬间的内存状态

func (MemoryStat) GetAvailablePercent

func (stat MemoryStat) GetAvailablePercent() float64

GetAvailablePercent

e.g. 51.035356521606445

func (MemoryStat) String

func (stat MemoryStat) String() string

Jump to

Keyboard shortcuts

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