utils

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSONTool = jsoniter.Config{UseNumber: true}.Froze()

Functions

func BatchFullOrTimeout

func BatchFullOrTimeout(runnerName string, stopped *int32, batchLen, batchSize int64, lastSend time.Time,
	maxBatchLen, maxBatchSize, maxBatchInterval int) bool

func CheckNotExistFile

func CheckNotExistFile(runnerName string, expireMap map[string]int64)

func DeepCopyByGob

func DeepCopyByGob(dst, src interface{})

func DeepCopyByJSON

func DeepCopyByJSON(dst, src interface{})

func GetFiles

func GetFiles(runnerName, dirPath string) (map[string]string, error)

获取指定目录下的所有文件和对应inode

func GetParseTestData

func GetParseTestData(line string, size int) []string

获取测试数据

func IsDir

func IsDir(path string) bool

func IsExist

func IsExist(path string) bool

IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.

func MongoDail

func MongoDail(host string, mode string, syncTimeoutInS int64) (session *mgo.Session, err error)

------------------------------------------------------------------------

func SetMode

func SetMode(s *mgo.Session, modeFriendly string, refresh bool)

func UpdateExpireMap

func UpdateExpireMap(runnerName string, fileMap map[string]string, expireMap map[string]int64)

func WriteZipToFile

func WriteZipToFile(zipf *zip.File, filename string) error

Types

type Backoff

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

func NewBackoff

func NewBackoff(factor, threshold float64, min, max time.Duration) *Backoff

func (*Backoff) Attempt

func (b *Backoff) Attempt() float64

func (*Backoff) Duration

func (b *Backoff) Duration() time.Duration

func (*Backoff) ForAttempt

func (b *Backoff) ForAttempt(attempt float64) time.Duration

func (*Backoff) Reset

func (b *Backoff) Reset()

type Collection

type Collection struct {
	*mgo.Collection
}

func (Collection) CloseSession

func (c Collection) CloseSession() (err error)

type MongoConfig

type MongoConfig struct {
	Host           string `json:"host"`
	DB             string `json:"db"`
	Mode           string `json:"mode"`
	SyncTimeoutInS int64  `json:"timeout"` // 以秒为单位
	Direct         bool   `json:"direct"`
}

type Stage

type Stage struct {
	Duration time.Duration
	Note     string
}

type Tracker

type Tracker struct {
	Start  time.Time
	Stages []Stage
}

func NewTracker

func NewTracker() *Tracker

func (*Tracker) Print

func (t *Tracker) Print() string

func (*Tracker) Reset

func (t *Tracker) Reset()

func (*Tracker) Track

func (t *Tracker) Track(stage string)

Directories

Path Synopsis
parse

Jump to

Keyboard shortcuts

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