Documentation
¶
Overview ¶
Package js is the JavaScript implementation of the lib.Runner and relative concepts for executing concurrent-safe JavaScript code.
Index ¶
- type ActiveVU
- type Bundle
- type BundleInstance
- type InitContext
- type Runner
- func (r *Runner) GetDefaultGroup() *lib.Group
- func (r *Runner) GetOptions() lib.Options
- func (r *Runner) GetSetupData() []byte
- func (r *Runner) HandleSummary(ctx context.Context, summary *lib.Summary) (map[string]io.Reader, error)
- func (r *Runner) IsExecutable(name string) bool
- func (r *Runner) MakeArchive() *lib.Archive
- func (r *Runner) NewVU(idLocal, idGlobal uint64, samplesOut chan<- metrics.SampleContainer) (lib.InitializedVU, error)
- func (r *Runner) SetOptions(opts lib.Options) error
- func (r *Runner) SetSetupData(data []byte)
- func (r *Runner) Setup(ctx context.Context, out chan<- metrics.SampleContainer) error
- func (r *Runner) Teardown(ctx context.Context, out chan<- metrics.SampleContainer) error
- type VU
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveVU ¶
type ActiveVU struct {
*VU
*lib.VUActivationParams
// contains filtered or unexported fields
}
ActiveVU holds a VU and its activation parameters
type Bundle ¶
type Bundle struct {
Filename *url.URL
Source string
Program *goja.Program
Options lib.Options
BaseInitContext *InitContext
RuntimeOptions lib.RuntimeOptions
CompatibilityMode lib.CompatibilityMode // parsed value
Vm *goja.Runtime
// contains filtered or unexported fields
}
A Bundle is a self-contained bundle of scripts and resources. You can use this to produce identical BundleInstance objects.
func NewBundle ¶
func NewBundle( piState *lib.TestPreInitState, src *loader.SourceData, filesystems map[string]afero.Fs, ) (*Bundle, error)
NewBundle creates a new bundle from a source file and a filesystem.
func NewBundleFromArchive ¶
NewBundleFromArchive creates a new bundle from an lib.Archive.
func (*Bundle) Instantiate ¶
func (b *Bundle) Instantiate(logger logrus.FieldLogger, vuID uint64) (*BundleInstance, error)
Instantiate creates a new runtime from this bundle.
type BundleInstance ¶
A BundleInstance is a self-contained instance of a Bundle.
type InitContext ¶
type InitContext struct {
// contains filtered or unexported fields
}
InitContext provides APIs for use in the init context.
TODO: refactor most/all of this state away, use common.InitEnvironment instead
func NewInitContext ¶
func NewInitContext( logger logrus.FieldLogger, rt *goja.Runtime, c *compiler.Compiler, compatMode lib.CompatibilityMode, filesystems map[string]afero.Fs, pwd *url.URL, ) *InitContext
NewInitContext creates a new initcontext with the provided arguments
type Runner ¶
type Runner struct {
Bundle *Bundle
BaseDialer net.Dialer
Resolver netext.Resolver
// TODO: Remove ActualResolver, it's a hack to simplify mocking in tests.
ActualResolver netext.MultiResolver
RPSLimit *rate.Limiter
RunTags *metrics.TagSet
// contains filtered or unexported fields
}
func New ¶
func New(piState *lib.TestPreInitState, src *loader.SourceData, filesystems map[string]afero.Fs) (*Runner, error)
New returns a new Runner for the provided source
func NewFromArchive ¶
NewFromArchive returns a new Runner from the source in the provided archive
func NewFromBundle ¶
func NewFromBundle(piState *lib.TestPreInitState, b *Bundle) (*Runner, error)
NewFromBundle returns a new Runner from the provided Bundle
func (*Runner) GetDefaultGroup ¶
func (*Runner) GetOptions ¶
func (*Runner) GetSetupData ¶
GetSetupData returns the setup data as json if Setup() was specified and executed, nil otherwise
func (*Runner) HandleSummary ¶
func (r *Runner) HandleSummary(ctx context.Context, summary *lib.Summary) (map[string]io.Reader, error)
HandleSummary calls the specified summary callback, if supplied.
func (*Runner) IsExecutable ¶
IsExecutable returns whether the given name is an exported and executable function in the script.
func (*Runner) MakeArchive ¶
func (*Runner) NewVU ¶
func (r *Runner) NewVU(idLocal, idGlobal uint64, samplesOut chan<- metrics.SampleContainer) (lib.InitializedVU, error)
NewVU returns a new initialized VU.
func (*Runner) SetSetupData ¶
SetSetupData saves the externally supplied setup data as json in the runner, so it can be used in VUs
type VU ¶
type VU struct {
BundleInstance
Runner *Runner
Transport *http.Transport
Dialer *netext.Dialer
CookieJar *cookiejar.Jar
TLSConfig *tls.Config
ID uint64 // local to the current instance
IDGlobal uint64 // global across all instances
Console *console
BPool *bpool.BufferPool
Samples chan<- metrics.SampleContainer
// contains filtered or unexported fields
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package common contains helpers for interacting with the JavaScript runtime.
|
Package common contains helpers for interacting with the JavaScript runtime. |
|
Package eventloop implements an event loop to be used thought js and it's subpackages
|
Package eventloop implements an event loop to be used thought js and it's subpackages |
|
k6
Package k6 implements the module imported as 'k6' from inside k6.
|
Package k6 implements the module imported as 'k6' from inside k6. |
|
k6/experimental
Package experimental includes experimental module features
|
Package experimental includes experimental module features |
|
k6/html
generated by js/modules/k6/html/gen/gen_elements.go; DO NOT EDIT
|
generated by js/modules/k6/html/gen/gen_elements.go; DO NOT EDIT |
|
k6/html/gen
command
|
|
|
k6/ws
Package ws implements a k6/ws for k6.
|
Package ws implements a k6/ws for k6. |
|
Package modulestest contains helpers to test js modules
|
Package modulestest contains helpers to test js modules |