generated from grafana/xk6-sql-driver-ramsql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule.go
40 lines (32 loc) · 860 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 mysql
import (
"github.com/grafana/sobek"
"go.k6.io/k6/js/modules"
)
// rootModule is the global module object type.
type rootModule struct {
driverID *sobek.Symbol
}
var _ modules.Module = &rootModule{}
// NewModuleInstance implements the modules.Module interface to return
// a new instance for each VU.
func (root *rootModule) NewModuleInstance(_ modules.VU) modules.Instance {
instance := &module{
exports: modules.Exports{
Default: root.driverID,
Named: make(map[string]interface{}),
},
}
instance.tlsExports()
return instance
}
// module represents an instance of the JavaScript module for every VU.
type module struct {
vu modules.VU
tlsConfig TLSConfig
exports modules.Exports
}
// Exports is representation of ESM exports of a module.
func (mod *module) Exports() modules.Exports {
return mod.exports
}