utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	READ_FILE_BUF_POOL_MAX_SIZE_UNBOUND      = 0
	READ_FILE_BUF_POOL_MAX_READ_SIZE_UNBOUND = 0
)
View Source
const (
	DEFAULT_LINUX_CLKTCK = 100
)

Variables

View Source
var (
	OSName         string
	OSNameNorm     string
	OSRelease      string
	OSReleaseVer   []int
	OSBtime        = getOsBtime()
	LinuxClktck    = int64(DEFAULT_LINUX_CLKTCK)
	LinuxClktckSec = 1. / float64(LinuxClktck)
	LinuxOsRelease = make(map[string]string)
)
View Source
var AvailableCpusCount = CountAvailableCPUs()
View Source
var ErrReadFileBufPotentialTruncation = errors.New("potential truncation")

Reading a file may be limited by a max size; if the cap is reached then it is possible that the file was truncated (note that stat system will report size 0 for /proc files, so it cannot be used to determine the actual size). Should such a condition occur, it should be treated as an error to signal potential truncation to the caller.

Functions

func CountAvailableCPUs

func CountAvailableCPUs() int

For linux count available CPUs based on CPU affinity, w/ a fallback on runtime:

func SplitWords

func SplitWords(s string) []string

Types

type ReadFileBufPool

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

func NewBufPool

func NewBufPool(maxPoolSize int) *ReadFileBufPool

func NewReadFileBufPool

func NewReadFileBufPool(maxPoolSize int, maxReadSize int64) *ReadFileBufPool

func (*ReadFileBufPool) GetBuf

func (p *ReadFileBufPool) GetBuf() *bytes.Buffer

func (*ReadFileBufPool) MaxPoolSize

func (p *ReadFileBufPool) MaxPoolSize() int

func (*ReadFileBufPool) MaxReadSize

func (p *ReadFileBufPool) MaxReadSize() int64

func (*ReadFileBufPool) ReadFile

func (p *ReadFileBufPool) ReadFile(path string) (*bytes.Buffer, error)

func (*ReadFileBufPool) ReturnBuf

func (p *ReadFileBufPool) ReturnBuf(b *bytes.Buffer)

Jump to

Keyboard shortcuts

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