Skip to content

Commit

Permalink
Rename modules.IsModuleV2 to modules.Module
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Nov 11, 2021
1 parent ca70290 commit 840b905
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions js/initcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ func (i *InitContext) requireModule(name string) (goja.Value, error) {
if !ok {
return nil, fmt.Errorf("unknown module: %s", name)
}
if modV2, ok := mod.(modules.IsModuleV2); ok {
instance := modV2.NewModuleInstance(&moduleInstanceCoreImpl{ctxPtr: i.ctxPtr})
if m, ok := mod.(modules.Module); ok {
instance := m.NewModuleInstance(&moduleInstanceCoreImpl{ctxPtr: i.ctxPtr})
return i.runtime.ToValue(toESModuleExports(instance.Exports())), nil
}
if perInstance, ok := mod.(modules.HasModuleInstancePerVU); ok {
Expand Down
6 changes: 3 additions & 3 deletions js/modules/k6/execution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ type (
)

var (
_ modules.IsModuleV2 = &RootModule{}
_ modules.Instance = &ModuleInstance{}
_ modules.Module = &RootModule{}
_ modules.Instance = &ModuleInstance{}
)

// New returns a pointer to a new RootModule instance.
func New() *RootModule {
return &RootModule{}
}

// NewModuleInstance implements the modules.IsModuleV2 interface to return
// NewModuleInstance implements the modules.Module interface to return
// a new instance for each VU.
func (*RootModule) NewModuleInstance(m modules.InstanceCore) modules.Instance {
mi := &ModuleInstance{InstanceCore: m}
Expand Down
6 changes: 3 additions & 3 deletions js/modules/k6/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ type (
)

var (
_ modules.IsModuleV2 = &RootModule{}
_ modules.Instance = &ModuleInstance{}
_ modules.Module = &RootModule{}
_ modules.Instance = &ModuleInstance{}
)

// NewModuleInstance implements modules.IsModuleV2 interface
// NewModuleInstance implements modules.Module interface
func (*RootModule) NewModuleInstance(m modules.InstanceCore) modules.Instance {
return &ModuleInstance{InstanceCore: m}
}
Expand Down
4 changes: 2 additions & 2 deletions js/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ type HasModuleInstancePerVU interface {
NewModuleInstancePerVU() interface{}
}

// IsModuleV2 is the interface js modules should implement to get the version 2 of the system
type IsModuleV2 interface {
// Module is the interface js modules should implement in order to get access to the InstanceCore
type Module interface {
// NewModuleInstance will get InstanceCore that should provide the module with *everything* it needs and return an
// Instance implementation (embedding the InstanceCore).
// This method will be called for *each* require/import and return an object for VUs.
Expand Down

0 comments on commit 840b905

Please sign in to comment.