Open na-- opened 2 years ago
As a bonus, the lengthy initialization of HTTP-specific things that currently happens during VU init: https://github.com/grafana/k6/blob/922c963f46466ba89deb506115a23b7bc7d2c822/js/runner.go#L157-L224
Would be moved to a much more appropriate place in the k6/http
module, e.g. here: https://github.com/grafana/k6/blob/8a475aba3b2f096509f7d0f41752f0a02738f7ef/js/modules/k6/http/http.go#L69-L72
(Extracted from https://github.com/grafana/k6/pull/2226, and somewhat connected to https://github.com/grafana/k6/issues/2258 and https://github.com/grafana/k6/issues/1802)
It would be quite nice if one pseudo-JS module is able to access the
modules.Instance
of another module. For example, ifk6/ws
is able to access the module instance ofk6/http
, though ideally any module (regardless of built-in or extension) should be able to access any other module.This will allow us to move a lot of the (mostly) HTTP-specific cruft from
lib.State
to a much more appropriate place: https://github.com/grafana/k6/blob/922c963f46466ba89deb506115a23b7bc7d2c822/lib/state.go#L56-L63 But still allow other parts of the codebase (likek6/ws
andk6/grpc
) to access the default HTTP transport or cookie jar, when they need to.