Skip to content

Commit

Permalink
Remove dependency on the js/ package (and goja) from lib/* packages
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Dec 13, 2022
1 parent 1896966 commit dbdcfc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion js/modules/k6/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (c *Client) Connect(addr string, params map[string]interface{}) (bool, erro
return false, fmt.Errorf("invalid grpc.connect() parameters: %w", err)
}

opts := grpcext.DefaultOptions(c.vu)
opts := grpcext.DefaultOptions(c.vu.State)

var tcred credentials.TransportCredentials
if !p.IsPlaintext {
Expand Down
12 changes: 6 additions & 6 deletions lib/netext/grpcext/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"

"github.com/sirupsen/logrus"
"go.k6.io/k6/js/modules"
"go.k6.io/k6/lib"
"go.k6.io/k6/metrics"

protov1 "github.com/golang/protobuf/proto" //nolint:staticcheck,nolintlint // this is the old v1 version
Expand Down Expand Up @@ -55,16 +55,16 @@ type Conn struct {

// DefaultOptions generates an option set
// with common options for requests from a VU.
func DefaultOptions(vu modules.VU) []grpc.DialOption {
func DefaultOptions(getState func() *lib.State) []grpc.DialOption {
dialer := func(ctx context.Context, addr string) (net.Conn, error) {
return vu.State().Dialer.DialContext(ctx, "tcp", addr)
return getState().Dialer.DialContext(ctx, "tcp", addr)
}

return []grpc.DialOption{
grpc.WithBlock(),
grpc.FailOnNonTempDialError(true),
grpc.WithReturnConnectionError(),
grpc.WithStatsHandler(statsHandler{vu: vu}),
grpc.WithStatsHandler(statsHandler{getState: getState}),
grpc.WithContextDialer(dialer),
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ func (c *Conn) Close() error {
}

type statsHandler struct {
vu modules.VU
getState func() *lib.State
}

// TagConn implements the grpcstats.Handler interface
Expand All @@ -195,7 +195,7 @@ func (statsHandler) TagRPC(ctx context.Context, _ *grpcstats.RPCTagInfo) context

// HandleRPC implements the grpcstats.Handler interface
func (h statsHandler) HandleRPC(ctx context.Context, stat grpcstats.RPCStats) {
state := h.vu.State()
state := h.getState()
stateRPC := getRPCState(ctx) //nolint:ifshort

// If the request is done by the reflection handler then the tags will be
Expand Down

0 comments on commit dbdcfc5

Please sign in to comment.