@@ -161,6 +161,14 @@ INFO[0000] false, 1 is NOT greater than 3 source=console
161
161
162
162
## Use the advanced module API
163
163
164
+ {{< admonition type="caution" >}}
165
+
166
+ The advanced module API adds significant complexity to your extension. Consider whether you actually need access to internal
167
+ k6 objects before implementing this pattern. For simple modules that don't need VU state or runtime access, the basic approach
168
+ shown above is sufficient.
169
+
170
+ {{< /admonition >}}
171
+
164
172
Suppose your extension needs access to internal k6 objects to, for example, inspect the state of the test during execution.
165
173
We will need to make slightly more complicated changes to the above example.
166
174
@@ -174,12 +182,6 @@ to access the [`modules.VU`](https://pkg.go.dev/go.k6.io/k6/js/modules#VU) to in
174
182
Additionally, there should be a root module implementation of the [ ` modules.Module ` ] ( https://pkg.go.dev/go.k6.io/k6/js/modules#Module )
175
183
interface to serve as a factory of ` Compare ` instances for each VU.
176
184
177
- {{< admonition type="caution" >}}
178
-
179
- The significance depends on the size of your module.
180
-
181
- {{< /admonition >}}
182
-
183
185
Here's what that would look like:
184
186
185
187
{{< code >}}
@@ -323,9 +325,6 @@ INFO[0000] Active VUs: 2, Iteration: 1, VU ID: 1, VU ID from runtime: 1 source=
323
325
INFO[0000] Active VUs: 2, Iteration: 2, VU ID: 2, VU ID from runtime: 2 source=console
324
326
```
325
327
326
- > For a more extensive usage example of this API, look at the
327
- > [ ` k6/execution ` ] ( https://github.com/grafana/k6/blob/master/js/modules/k6/execution/execution.go ) module.
328
-
329
328
## Things to keep in mind
330
329
331
330
- The code in the ` default ` function (or another function specified by
0 commit comments