helpers

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalBufferPool = NewBufferPool()

Functions

func FlattenMultiError

func FlattenMultiError(mErr *multierror.Error) error

FlattenMultiError return nil or original error if multierror does not have more than one error

func HasDeprecatedFields added in v0.6.8

func HasDeprecatedFields(rawJson []byte, deprecatedPaths []string) error

HasDeprecatedFields check json if keys exist at provided paths, if any exist report error

func IsContextTriggered

func IsContextTriggered(ctx context.Context) bool

IsContextTriggered check if context is "done"

func RecoverWithError

func RecoverWithError(panicErr *error)

RecoverWithError recovers from panic and sets error to panicErr

func RecoverWithErrorFunc added in v0.6.17

func RecoverWithErrorFunc(f func()) error

RecoverWithErrorFunc recovers from panic and returns panic error

func TrueCause added in v0.5.7

func TrueCause(err error) error

TrueCause of error, in the case of a multi error, the first error in list will be used

func WaitFor

func WaitFor(ctx context.Context, duration time.Duration)

WaitFor context or timeout

Types

type Buffer

type Buffer struct {
	B     *strings.Builder
	Error error
}

func NewBuffer

func NewBuffer() *Buffer

NewBuffer creates and initializes a new string Buffer.

func (*Buffer) Reset

func (buffer *Buffer) Reset()

Reset resets the buffer to be empty,

func (*Buffer) String

func (buffer *Buffer) String() string

String returns the contents of the unread portion of the buffer as a string. If the Buffer is a nil pointer, it returns "<nil>".

func (*Buffer) WriteByte

func (buffer *Buffer) WriteByte(c byte)

WriteByte appends the byte c to the buffer, growing the buffer as needed.

func (*Buffer) WriteBytes

func (buffer *Buffer) WriteBytes(p []byte)

Write bytes to buffer, errors written to stderr

func (*Buffer) WriteRune

func (buffer *Buffer) WriteRune(r rune)

WriteRune appends the UTF-8 encoding of Unicode code point r to the buffer, errors written to stderr

func (*Buffer) WriteString

func (buffer *Buffer) WriteString(s string)

WriteString to buffer, errors written to stderr

func (*Buffer) WriteTo

func (buffer *Buffer) WriteTo(w io.Writer)

WriteTo writes data to w until the buffer is drained or an error occurs., errors written to stderr

type BufferPool added in v0.6.21

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

func NewBufferPool added in v0.6.21

func NewBufferPool() *BufferPool

func (*BufferPool) Get added in v0.6.21

func (bp *BufferPool) Get() *bytes.Buffer

func (*BufferPool) Put added in v0.6.21

func (bp *BufferPool) Put(buf *bytes.Buffer)

type DataPath added in v0.6.8

type DataPath string

DataPath string which can be return as substring splitted on / (slash)

func NewDataPath added in v0.6.8

func NewDataPath(path string) DataPath

NewDataPath new instance

func (DataPath) Contains added in v0.6.8

func (path DataPath) Contains(val string) bool

Contains Check if path contains value

func (DataPath) Lookup added in v0.6.8

func (path DataPath) Lookup(data json.RawMessage) (json.RawMessage, error)

Lookup object in path, if data found is of type string it will be quoted with ""

func (DataPath) LookupMulti added in v0.6.8

func (path DataPath) LookupMulti(data json.RawMessage, separator string) ([]json.RawMessage, error)

LookupMulti objects with subpaths under an array in a path

func (DataPath) LookupNoQuotes added in v0.6.8

func (path DataPath) LookupNoQuotes(data json.RawMessage) (json.RawMessage, error)

LookupNoQuotes object in path, data of type string will not be quoted

func (DataPath) Set added in v0.6.15

func (path DataPath) Set(data []byte, newValue []byte) ([]byte, error)

Set look object in path and set to new object

func (*DataPath) String added in v0.6.8

func (path *DataPath) String() string

String string representation of datapath

type DistributionSettings

type DistributionSettings struct {
	// Type of timer delay
	Type DistributionType `json:"type" displayname:"Distribution type" doc-key:"thinktime.type"`
	// Delay static delay when using static timer delay
	Delay float64 `json:"delay,omitempty" displayname:"Static delay" doc-key:"thinktime.delay"`
	// Mean value
	Mean float64 `json:"mean,omitempty" displayname:"Mean value" doc-key:"thinktime.mean"`
	// Deviation value
	Deviation float64 `json:"dev,omitempty" displayname:"Deviation value" doc-key:"thinktime.dev"`
}

DistributionSettings think time settings

func (DistributionSettings) GetActionInfo

func (settings DistributionSettings) GetActionInfo() string

GetActionInfo get information for action details logging

func (DistributionSettings) GetMax

func (settings DistributionSettings) GetMax() (float64, error)

GetMax value

func (DistributionSettings) GetMin

func (settings DistributionSettings) GetMin() (float64, error)

GetMin value

func (DistributionSettings) RandDuration added in v0.4.11

func (settings DistributionSettings) RandDuration(rnd Randomizer) (time.Duration, error)

RandDuration returns a random duration

func (DistributionSettings) Validate

func (settings DistributionSettings) Validate() error

Validate DistributionSettings

type DistributionType

type DistributionType int

DistributionType type of distribution

const (
	// StaticDistribution fixed distribution
	StaticDistribution DistributionType = iota
	// UniformDistribution uniform distribution, defined by "mean" and "dev"
	UniformDistribution
)

func (DistributionType) GetEnumMap

func (value DistributionType) GetEnumMap() *enummap.EnumMap

GetEnumMap of DistributionType

func (DistributionType) MarshalJSON

func (value DistributionType) MarshalJSON() ([]byte, error)

MarshalJSON marshal ThinkTime type

func (*DistributionType) UnmarshalJSON

func (value *DistributionType) UnmarshalJSON(arg []byte) error

UnmarshalJSON unmarshal DistributionType

type NoDataFound added in v0.6.8

type NoDataFound string

NoDataFound no data found in path

func (NoDataFound) Error added in v0.6.8

func (err NoDataFound) Error() string

Error no data found in data path

type NoStepsError added in v0.6.8

type NoStepsError string

NoStepsError no steps to take in data path

func (NoStepsError) Error added in v0.6.8

func (err NoStepsError) Error() string

Error no steps in data path

type Params

type Params map[string]string

Params map with URL parameters

func (Params) String

func (params Params) String() string

String returns parameters as string with the format ?param1=val1&param2=val2, parameter order is not guaranteed

type Randomizer added in v0.4.11

type Randomizer interface {
	Rand(max int) int
	RandWeightedInt(weights []int) (int, error)
	RandIntPos(ints []int) (int, int, error)
	RandDuration(minDuration, maxDuration time.Duration) (time.Duration, error)
	Reset(instance, session uint64, onlyinstanceSeed bool)
}

type RowFile

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

RowFile path to file on disc to read into memory

func NewRowFile

func NewRowFile(filepath string) (RowFile, error)

NewRowFile reads rows from file path into memory

func (*RowFile) IsEmpty

func (file *RowFile) IsEmpty() bool

IsEmpty reports true if a filepath is not set

func (RowFile) MarshalJSON

func (file RowFile) MarshalJSON() ([]byte, error)

MarshalJSON marshal filepath to JSON

func (*RowFile) Rows

func (file *RowFile) Rows() []string

Rows in memory from file, to read into memory, either ReadRows or UnmarshalJSON needs to have been called

func (RowFile) String

func (file RowFile) String() string

String implements stringer interface

func (RowFile) TreatAs

func (file RowFile) TreatAs() string

func (*RowFile) UnmarshalJSON

func (file *RowFile) UnmarshalJSON(arg []byte) error

UnmarshalJSON reads file from filepath into memory

type StringBool added in v0.6.21

type StringBool bool

StringBool resolves boolean sent as strings, json unmarshal defaults to true

func (*StringBool) UnmarshalJSON added in v0.6.21

func (sb *StringBool) UnmarshalJSON(arg []byte) error

UnmarshalJSON StringBool

type TimeDuration

type TimeDuration time.Duration

func (TimeDuration) MarshalJSON

func (duration TimeDuration) MarshalJSON() ([]byte, error)

MarshalJSON marshal time buffer duration to JSON

func (*TimeDuration) UnmarshalJSON

func (duration *TimeDuration) UnmarshalJSON(arg []byte) error

UnmarshalJSON unmarshal time buffer duration from JSON

type TreatAs

type TreatAs interface {
	/*
		Supported types:
			String
			Int
			Float
			Enum
			Bool
			Slice
			SliceElement
			StringMap
			StringMapElement
	*/
	TreatAs() string
}

Implement this interface to override the type a struct is treated as by the GUI

type UniqueInts added in v0.5.3

type UniqueInts map[int]struct{}

func (*UniqueInts) AddValue added in v0.5.3

func (u *UniqueInts) AddValue(v int)

AddValue to unique list

func (*UniqueInts) Array added in v0.5.3

func (u *UniqueInts) Array() []int

Array of unique integers

func (*UniqueInts) HasValue added in v0.5.3

func (u *UniqueInts) HasValue(v int) bool

HasValue test if collection includes value

Jump to

Keyboard shortcuts

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