Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completely remove experimental GRPC module #3530

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion js/jsmodules.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package js

import (
"errors"
"sync"

"go.k6.io/k6/ext"
"go.k6.io/k6/js/common"
"go.k6.io/k6/js/modules"
"go.k6.io/k6/js/modules/k6"
"go.k6.io/k6/js/modules/k6/crypto"
Expand Down Expand Up @@ -38,7 +40,6 @@ func getInternalJSModules() map[string]interface{} {
"k6/experimental/redis": redis.New(),
"k6/experimental/webcrypto": webcrypto.New(),
"k6/experimental/websockets": &expws.RootModule{},
"k6/experimental/grpc": grpc.NewExperimental(),
"k6/experimental/timers": newWarnExperimentalModule(timers.New(),
"k6/experimental/timers is now part of the k6 core, please change your imports to use k6/timers instead."+
" The k6/experimental/timers will be removed in k6 v0.52.0"),
Expand All @@ -50,6 +51,10 @@ func getInternalJSModules() map[string]interface{} {
"k6/http": http.New(),
"k6/metrics": metrics.New(),
"k6/ws": ws.New(),
"k6/experimental/grpc": newRemovedModule(
"k6/experimental/grpc has been graduated, please use k6/net/grpc instead." +
" See https://grafana.com/docs/k6/latest/javascript-api/k6-net-grpc/ for more information.",
),
}
}

Expand Down Expand Up @@ -83,3 +88,17 @@ func (w *warnExperimentalModule) NewModuleInstance(vu modules.VU) modules.Instan
w.once.Do(func() { vu.InitEnv().Logger.Warn(w.msg) })
return w.base.NewModuleInstance(vu)
}

type removedModule struct {
errMsg string
}

func newRemovedModule(errMsg string) modules.Module {
return &removedModule{errMsg: errMsg}
}

func (rm *removedModule) NewModuleInstance(vu modules.VU) modules.Instance {
common.Throw(vu.Runtime(), errors.New(rm.errMsg))

return nil
}
21 changes: 1 addition & 20 deletions js/modules/k6/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package grpc
import (
"errors"
"fmt"
"sync"

"github.com/dop251/goja"
"github.com/mstoykov/k6-taskqueue-lib/taskqueue"
Expand All @@ -16,9 +15,7 @@ import (
type (
// RootModule is the global module instance that will create module
// instances for each VU.
RootModule struct {
warnAboutExperimental *sync.Once
}
RootModule struct{}

// ModuleInstance represents an instance of the GRPC module for every VU.
ModuleInstance struct {
Expand All @@ -38,13 +35,6 @@ func New() *RootModule {
return &RootModule{}
}

// NewExperimental returns a pointer to a new RootModule instance.
func NewExperimental() *RootModule {
return &RootModule{
warnAboutExperimental: &sync.Once{},
}
}

// NewModuleInstance implements the modules.Module interface to return
// a new instance for each VU.
func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance {
Expand All @@ -53,15 +43,6 @@ func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance {
common.Throw(vu.Runtime(), fmt.Errorf("failed to register GRPC module metrics: %w", err))
}

if r.warnAboutExperimental != nil {
r.warnAboutExperimental.Do(func() {
vu.InitEnv().Logger.Warn(
"k6/experimental/grpc is now part of the k6 core, please change your imports to use k6/net/grpc instead." +
" The k6/experimental/grpc will be removed in k6 v0.51.0",
)
})
}

mi := &ModuleInstance{
vu: vu,
exports: make(map[string]interface{}),
Expand Down