common

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRandSource = NewRandSource()

Functions

func Bind

func Bind(rt *goja.Runtime, v interface{}, ctxPtr *context.Context) map[string]interface{}

func BindToGlobal

func BindToGlobal(rt *goja.Runtime, data map[string]interface{}) func()

Binds an object's members to the global scope. Returns a function that un-binds them. Note that this will panic if passed something that isn't a struct; please don't do that.

func FieldName

func FieldName(t reflect.Type, f reflect.StructField) string

Returns the JS name for an exported struct field. The name is snake_cased, with respect for certain common initialisms (URL, ID, HTTP, etc).

func GetRuntime

func GetRuntime(ctx context.Context) *goja.Runtime

func MethodName

func MethodName(t reflect.Type, m reflect.Method) string

Returns the JS name for an exported method. The first letter of the method's name is lowercased, otherwise it is unaltered.

func NewRandSource

func NewRandSource() goja.RandSource

func RunString

func RunString(rt *goja.Runtime, src string) (goja.Value, error)

Runs an ES6 string in the given runtime. Use this rather than writing ES5 in tests.

func Throw

func Throw(rt *goja.Runtime, err error)

Throws a JS error; avoids re-wrapping GoErrors.

func WithRuntime

func WithRuntime(ctx context.Context, rt *goja.Runtime) context.Context

func WithState

func WithState(ctx context.Context, state *State) context.Context

Types

type FieldNameMapper

type FieldNameMapper struct{}

FieldNameMapper for goja.Runtime.SetFieldNameMapper()

func (FieldNameMapper) FieldName

func (FieldNameMapper) MethodName

func (FieldNameMapper) MethodName(t reflect.Type, m reflect.Method) string

type State

type State struct {
	// Global options.
	Options lib.Options

	// Logger. Avoid using the global logger.
	Logger *log.Logger

	// Current group; all emitted metrics are tagged with this.
	Group *lib.Group

	// Networking equipment.
	HTTPTransport http.RoundTripper
	Dialer        *netext.Dialer
	CookieJar     *cookiejar.Jar

	// Rate limits.
	RPSLimit *rate.Limiter

	// Sample buffer, emitted at the end of the iteration.
	Samples []stats.Sample

	// Bytes sent and received during this iteration. Use `sync/atomic`.
	BytesRead, BytesWritten int64

	// Buffer pool; use instead of allocating fresh buffers when possible.
	BPool *bpool.BufferPool

	Vu, Iteration int64
}

Provides volatile state for a VU.

func GetState

func GetState(ctx context.Context) *State

Jump to

Keyboard shortcuts

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