util

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const COLLSCAN = "COLLSCAN"

COLLSCAN constance

Variables

View Source
var Favorites = FavoritesDoc{
	Sports: []string{"Baseball", "Boxing", "Dodgeball", "Figure skating", "Football", "Horse racing", "Mountaineering", "Skateboard", "Ski", "Soccer"},
	Music:  []string{"Blues", "Classical", "Country", "Easy Listening", "Electronic", "Hip Pop", "Jazz", "Opera", "Soul", "Rock"},
	Cities: []string{"Atlanta", "Bangkok", "Beijing", "London", "Paris", "Singapore", "New York", "Istanbul", "Dubai", "Taipei"},
	Books:  []string{"Journey to the West", "The Lord of the Rings", "In Search of Lost Time", "Don Quixote", "Ulysses", "The Great Gatsby", "Moby Dick", "Hamlet", "War and Peace", "The Odyssey"},
	Movies: []string{"The Godfather", "The Shawshank Redemption", "Schindler's List", "Raging Bull", "Casablanca", "Citizen Kane", "Gone with the Wind", "The Wizard of Oz", "One Flew Over the Cuckoo's Nest", "Lawrence of Arabia"},
}

Favorites constance

Functions

func CloneDoc

func CloneDoc(doc bson.M) bson.M

CloneDoc clones a doc and assign a _id

func CountLines

func CountLines(reader *bufio.Reader) (int, error)

CountLines count number of '\n'

func Echo added in v1.0.1

func Echo(doc bson.M)

Echo echoes bson.M

func GetDemoDoc

func GetDemoDoc() bson.M

GetDemoDoc returns a demo document

func GetDemoFromFile

func GetDemoFromFile(filename string) string

GetDemoFromFile returns a doc from a template

func GetDemoSchema

func GetDemoSchema() string

GetDemoSchema returns a demo doc

func GetDocByTemplate

func GetDocByTemplate(filename string, meta bool) (bson.M, error)

GetDocByTemplate returns a bson.M document

func GetEmailAddress

func GetEmailAddress() string

GetEmailAddress exposes getEmailAddress()

func GetRandomizedDoc

func GetRandomizedDoc(buf []byte, meta bool) (bson.M, error)

GetRandomizedDoc returns a randomized doc from byte string

func HTTPDigest added in v1.1.0

func HTTPDigest(method string, uri string, username string, password string, headers map[string]string) (*http.Response, error)

HTTPDigest --digest

func MilliToTimeString added in v1.1.0

func MilliToTimeString(milli float64) string

MilliToTimeString converts milliseconds to time string, e.g. 1.5m

func NewReader

func NewReader(file *os.File) (*bufio.Reader, error)

NewReader returns a reader from either a gzip or plain file

func RandomizeDocument

func RandomizeDocument(doc *map[string]interface{}, f interface{}, meta bool)

RandomizeDocument traverses a doc and replace values with random values according to their data type.

Types

type FavoritesDoc

type FavoritesDoc struct {
	Sports []string
	Music  []string
	Cities []string
	Books  []string
	Movies []string
}

FavoritesDoc -

type FavoritesSchema

type FavoritesSchema struct {
	ID            string `json:"_id" bson:"_id"`
	FavoriteBook  string `json:"favoriteBook" bson:"favoriteBook"`
	FavoriteCity  string `json:"favoriteCity" bson:"favoriteCity"`
	FavoriteMovie string `json:"favoriteMovie" bson:"favoriteMovie"`
	FavoriteMusic string `json:"favoriteMusic" bson:"favoriteMusic"`
	FavoriteSport string `json:"favoriteSport" bson:"favoriteSport"`
}

FavoritesSchema -

type LogInfo

type LogInfo struct {
	OpsPatterns    []OpPerformanceDoc
	OutputFilename string
	SlowOps        []SlowOps
	// contains filtered or unexported fields
}

LogInfo keeps loginfo struct

func NewLogInfo added in v1.1.0

func NewLogInfo(filename string) *LogInfo

NewLogInfo -

func (*LogInfo) Analyze added in v1.1.0

func (li *LogInfo) Analyze() (string, error)

Analyze -

func (*LogInfo) Parse added in v1.1.0

func (li *LogInfo) Parse() error

Parse -

func (*LogInfo) SetCollscan added in v1.1.0

func (li *LogInfo) SetCollscan(collscan bool)

SetCollscan -

func (*LogInfo) SetSilent added in v1.1.0

func (li *LogInfo) SetSilent(silent bool)

SetSilent -

func (*LogInfo) SetVerbose added in v1.1.0

func (li *LogInfo) SetVerbose(verbose bool)

SetVerbose -

type OpPerformanceDoc

type OpPerformanceDoc struct {
	Command    string // count, delete, find, remove, and update
	Count      int    // number of ops
	Filter     string // query pattern
	MaxMilli   int    // max millisecond
	Namespace  string // database.collectin
	Scan       string // COLLSCAN
	TotalMilli int    // total milliseconds
	Index      string // index used
}

OpPerformanceDoc stores performance data

type SlowOps added in v1.1.0

type SlowOps struct {
	Milli int
	Log   string
}

SlowOps holds slow ops log and time

type WaitGroup

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

WaitGroup -

func NewWaitGroup

func NewWaitGroup(size int) *WaitGroup

NewWaitGroup -

func (*WaitGroup) Add

func (wg *WaitGroup) Add(num int)

Add -

func (*WaitGroup) Done

func (wg *WaitGroup) Done()

Done -

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait()

Wait -

Jump to

Keyboard shortcuts

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