Documentation
      ¶
    
    
  
    
  
    Index ¶
- func Bind(rt *goja.Runtime, v interface{}, ctxPtr *context.Context) map[string]interface{}
 - func BindToGlobal(rt *goja.Runtime, data map[string]interface{}) func()
 - func FieldName(t reflect.Type, f reflect.StructField) string
 - func GetRuntime(ctx context.Context) *goja.Runtime
 - func MethodName(t reflect.Type, m reflect.Method) string
 - func NewRandSource() goja.RandSource
 - func RunString(rt *goja.Runtime, src string) (goja.Value, error)
 - func Throw(rt *goja.Runtime, err error)
 - func WithRuntime(ctx context.Context, rt *goja.Runtime) context.Context
 - func WithState(ctx context.Context, state *State) context.Context
 - type FieldNameMapper
 - type InitContextError
 - type State
 
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindToGlobal ¶
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 MethodName ¶
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
NewRandSource is copied from goja's source code: https://github.com/dop251/goja/blob/master/goja/main.go#L44 The returned RandSource is NOT safe for concurrent use: https://golang.org/pkg/math/rand/#NewSource
func RunString ¶
Runs an ES6 string in the given runtime. Use this rather than writing ES5 in tests.
Types ¶
type FieldNameMapper ¶
type FieldNameMapper struct{}
    FieldNameMapper for goja.Runtime.SetFieldNameMapper()
func (FieldNameMapper) FieldName ¶
func (FieldNameMapper) FieldName(t reflect.Type, f reflect.StructField) string
func (FieldNameMapper) MethodName ¶
type InitContextError ¶ added in v0.23.0
type InitContextError string
InitContextError is an error that happened during the a test init context
func NewInitContextError ¶ added in v0.23.0
func NewInitContextError(msg string) InitContextError
NewInitContextError returns a new InitContextError with the provided message
func (InitContextError) Error ¶ added in v0.23.0
func (i InitContextError) Error() string
func (InitContextError) String ¶ added in v0.23.0
func (i InitContextError) String() 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.
	Transport http.RoundTripper
	Dialer    *netext.Dialer
	CookieJar *cookiejar.Jar
	TLSConfig *tls.Config
	// Rate limits.
	RPSLimit *rate.Limiter
	// Sample channel, possibly buffered
	Samples chan<- stats.SampleContainer
	// Buffer pool; use instead of allocating fresh buffers when possible.
	// TODO: maybe use https://golang.org/pkg/sync/#Pool ?
	BPool *bpool.BufferPool
	Vu, Iteration int64
}
    State provides the volatile state for a VU.