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: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func BatchFullOrTimeout added in v1.5.4

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

func CheckNotExistFile added in v1.5.4

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

func DeepCopyByGob added in v1.5.4

func DeepCopyByGob(dst, src interface{})

func DeepCopyByJSON added in v1.5.4

func DeepCopyByJSON(dst, src interface{})

func GetFiles added in v1.5.4

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

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

func GetParseTestData added in v1.5.3

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

获取测试数据

func IsDir added in v1.5.5

func IsDir(path string) bool

func IsExist added in v1.5.2

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 IsGzipped added in v1.5.4

func IsGzipped(data []byte) bool

gzip 前两位是固定的: https://stackoverflow.com/questions/6059302/how-to-check-if-a-file-is-gzip-compressed

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 added in v1.5.4

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

func WriteZipToFile added in v1.5.4

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

Types

type Backoff added in v1.5.5

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

func NewBackoff added in v1.5.5

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

func (*Backoff) Attempt added in v1.5.5

func (b *Backoff) Attempt() float64

func (*Backoff) Duration added in v1.5.5

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

func (*Backoff) ForAttempt added in v1.5.5

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

func (*Backoff) Reset added in v1.5.5

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 added in v1.5.4

type Stage struct {
	Duration time.Duration
	Note     string
}

type Tracker added in v1.5.4

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

func NewTracker added in v1.5.4

func NewTracker() *Tracker

func (*Tracker) Print added in v1.5.4

func (t *Tracker) Print() string

func (*Tracker) Reset added in v1.5.4

func (t *Tracker) Reset()

func (*Tracker) Track added in v1.5.4

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