-
Notifications
You must be signed in to change notification settings - Fork 2
/
module.go
40 lines (33 loc) · 838 Bytes
/
module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package generator
import (
"go.k6.io/k6/js/modules"
)
func init() {
modules.Register("k6/x/opentelemetry", New())
}
type (
RootModule struct{}
ModuleInstance struct {
generator *Generator
}
)
var (
_ modules.Instance = &ModuleInstance{}
_ modules.Module = &RootModule{}
)
// New returns a pointer to a new RootModule instance.
func New() *RootModule {
return &RootModule{}
}
// NewModuleInstance implements the modules.Module interface returning a new instance for each VU.
func (*RootModule) NewModuleInstance(_ modules.VU) modules.Instance {
return &ModuleInstance{
generator: NewGenerator(),
}
}
// Exports implements the modules.Instance interface and returns the exported types for the JS module.
func (mi *ModuleInstance) Exports() modules.Exports {
return modules.Exports{
Default: mi.generator,
}
}