common

package
Version: v0.0.0-...-fb642de Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2014 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsoleErr

func ConsoleErr(cmd *cobra.Command, str string)

func ConsoleRun

func ConsoleRun(runner RunCmd, workerType string, ui UI, cmd *cobra.Command, args []string)

func DatastoreBytesToValues

func DatastoreBytesToValues(input []byte) (map[string]string, error)

func DatastoreLoad

func DatastoreLoad(conf *DatastoreConfig, ds Datastore, rv *Result) error

func DatastoreRun

func DatastoreRun(conf *DatastoreConfig, ds Datastore, rv *Result) error

func DatastoreValuesToBytes

func DatastoreValuesToBytes(values map[string]string) ([]byte, error)

func DatastoreWork

func DatastoreWork(ds Datastore, rv *Result) error

func HasPort

func HasPort(s string) bool

Given a string of the form "host", "host:port", or "[ipv6::address]:port", return true if the string includes a port. TOOD(pquerna): move to netutils or such?

Types

type BasicConfig

type BasicConfig struct {
	Url         string
	Cluster     string
	NumRequests int64
	Concurrency int
}

func (*BasicConfig) AddFlags

func (conf *BasicConfig) AddFlags(flags *flag.FlagSet)

func (*BasicConfig) GetBasicConfig

func (conf *BasicConfig) GetBasicConfig() *BasicConfig

func (*BasicConfig) GetDatastoreConfig

func (conf *BasicConfig) GetDatastoreConfig() *DatastoreConfig

func (*BasicConfig) GetEtcdConfig

func (conf *BasicConfig) GetEtcdConfig() *EtcdConfig

func (*BasicConfig) GetHttpConfig

func (conf *BasicConfig) GetHttpConfig() *HttpConfig

func (*BasicConfig) GetSwiftConfig

func (conf *BasicConfig) GetSwiftConfig() *SwiftConfig

func (*BasicConfig) Validate

func (conf *BasicConfig) Validate() error

type ConfigGetter

type ConfigGetter interface {
	// TODO(pquerna): This interface sucks. IT REALLY SUCKS. FIX ME.
	GetBasicConfig() *BasicConfig
	GetDatastoreConfig() *DatastoreConfig
	GetHttpConfig() *HttpConfig
	GetEtcdConfig() *EtcdConfig
	GetSwiftConfig() *SwiftConfig
	Validate() error
}

type Datastore

type Datastore interface {
	Config() ConfigGetter
	Insert(table string, key string, value DatastoreObj) error
	Read(table string, key string) (DatastoreObj, error)
	Update(table string, key string, value DatastoreObj) error
	Scan(table string, startKey string, count int) ([]DatastoreObj, error)
	Delete(table string, key string) error
}

type DatastoreConfig

type DatastoreConfig struct {
	Mode        string
	Records     int64
	AtRecord    int64
	FieldCount  int
	FieldSize   int
	ReadRatio   float64
	UpdateRatio float64
}

func (*DatastoreConfig) AddFlags

func (conf *DatastoreConfig) AddFlags(flags *flag.FlagSet)

func (*DatastoreConfig) GetDatastoreConfig

func (conf *DatastoreConfig) GetDatastoreConfig() *DatastoreConfig

func (*DatastoreConfig) Validate

func (conf *DatastoreConfig) Validate() error

type DatastoreObj

type DatastoreObj map[string]string

type EtcdConfig

type EtcdConfig struct {
	BasicConfig
}

func (*EtcdConfig) GetEtcdConfig

func (conf *EtcdConfig) GetEtcdConfig() *EtcdConfig

func (*EtcdConfig) Validate

func (conf *EtcdConfig) Validate() error

type HttpConfig

type HttpConfig struct {
	BasicConfig
	Method    string
	Keepalive bool
}

func (*HttpConfig) AddFlags

func (conf *HttpConfig) AddFlags(flags *flag.FlagSet)

func (*HttpConfig) GetHttpConfig

func (conf *HttpConfig) GetHttpConfig() *HttpConfig

func (*HttpConfig) Validate

func (conf *HttpConfig) Validate() error

type Result

type Result struct {
	Type     string
	Id       string
	Error    bool
	Start    time.Time
	Duration time.Duration
	// TODO: should we just do a map[string]interface{}?
	Meta    map[string]string
	Metrics map[string]float64
}

func NewResult

func NewResult(taskType string, id string) *Result

func (*Result) Done

func (r *Result) Done()

Calling Done() multiple times is OK, some Tasks will call it before they return, because they spend significant time extracting metadata.

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

type ResultArchiveReader

type ResultArchiveReader struct {
	Path string
	// contains filtered or unexported fields
}

func NewResultArchiveReader

func NewResultArchiveReader(path string) *ResultArchiveReader

func (*ResultArchiveReader) Close

func (rar *ResultArchiveReader) Close() error

func (*ResultArchiveReader) Entry

func (rr *ResultArchiveReader) Entry() *Result

func (*ResultArchiveReader) Reset

func (rr *ResultArchiveReader) Reset()

func (*ResultArchiveReader) Scan

func (rr *ResultArchiveReader) Scan() bool

type ResultArchiveWriter

type ResultArchiveWriter struct {
	Path string
	// contains filtered or unexported fields
}

func NewResultArchiveWriter

func NewResultArchiveWriter() *ResultArchiveWriter

func (*ResultArchiveWriter) Close

func (raw *ResultArchiveWriter) Close() error

func (*ResultArchiveWriter) Remove

func (raw *ResultArchiveWriter) Remove() error

func (*ResultArchiveWriter) Write

func (raw *ResultArchiveWriter) Write(rv *Result) error

type RunCmd

type RunCmd func(ui UI, taskType string) error

type SwiftConfig

type SwiftConfig struct {
	BasicConfig
	DatastoreConfig
	Username string
	ApiKey   string
	AuthUrl  string
	Region   string
}

func (*SwiftConfig) AddFlags

func (conf *SwiftConfig) AddFlags(flags *flag.FlagSet)

func (*SwiftConfig) GetDatastoreConfig

func (conf *SwiftConfig) GetDatastoreConfig() *DatastoreConfig

func (*SwiftConfig) GetSwiftConfig

func (conf *SwiftConfig) GetSwiftConfig() *SwiftConfig

func (*SwiftConfig) Validate

func (conf *SwiftConfig) Validate() error

type UI

type UI interface {
	WorkStart(numTodo int64)
	WorkStatus(numDone int64)
	WorkEnd()
	ConfigSet(config ConfigGetter)
	ConfigGet() ConfigGetter
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL