Skip to content

Commit

Permalink
Merge pull request #10 from mstoykov/useSobek
Browse files Browse the repository at this point in the history
Change to using sobek instead of goja
  • Loading branch information
szkiba authored Jun 10, 2024
2 parents e0e807b + 50f02ac commit 26647b9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 241 deletions.
10 changes: 5 additions & 5 deletions g0/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"time"

"github.com/dop251/goja"
"github.com/grafana/sobek"
"go.k6.io/k6/js/common"
"go.k6.io/k6/js/modules"
)
Expand Down Expand Up @@ -57,16 +57,16 @@ func (w *contextWrapper) eval(expr string) any {
return w.export(val)
}

func (w *contextWrapper) export(val goja.Value) any {
if function, ok := goja.AssertFunction(val); ok {
func (w *contextWrapper) export(val sobek.Value) any {
if function, ok := sobek.AssertFunction(val); ok {
return func(goargs ...any) any {
jsargs := make([]goja.Value, 0, len(goargs))
jsargs := make([]sobek.Value, 0, len(goargs))

for _, v := range goargs {
jsargs = append(jsargs, w.vu.Runtime().ToValue(v))
}

val, err := function(goja.Undefined(), jsargs...)
val, err := function(sobek.Undefined(), jsargs...)
if err != nil {
common.Throw(w.vu.Runtime(), err)
}
Expand Down
53 changes: 9 additions & 44 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,63 +1,32 @@
module github.com/szkiba/xk6-g0

go 1.19
go 1.20

require (
github.com/PaesslerAG/gval v1.0.0
github.com/PaesslerAG/jsonpath v0.1.1
github.com/PuerkitoBio/goquery v1.9.1
github.com/brianvoe/gofakeit/v6 v6.22.0
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204
github.com/go-resty/resty/v2 v2.7.0
github.com/grafana/sobek v0.0.0-20240607083612-4f0cd64f4e78
github.com/imdario/mergo v0.3.16
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify/_codegen v0.0.0-20230530093840-f97607b89807
github.com/tidwall/gjson v1.17.1
github.com/traefik/yaegi v0.14.3
go.k6.io/k6 v0.51.1-0.20240529084813-39951aba679a
go.k6.io/k6 v0.51.1-0.20240610082146-1f01a9bc2365
)

require (
buf.build/gen/go/gogo/protobuf/protocolbuffers/go v1.31.0-20210810001428-4df00b267f94.1 // indirect
buf.build/gen/go/prometheus/prometheus/protocolbuffers/go v1.31.0-20230627135113-9a12bc2590d2.1 // indirect
github.com/DataDog/datadog-go v0.0.0-20180330214955-e67964b4021a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bufbuild/protocompile v0.8.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chromedp/cdproto v0.0.0-20221023212508-67ada9507fb2 // indirect
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dop251/goja v0.0.0-20240516125602-ccbae20bcec2 // indirect
github.com/evanw/esbuild v0.21.2 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grafana/xk6-browser v1.5.1 // indirect
github.com/grafana/xk6-dashboard v0.7.3 // indirect
github.com/grafana/xk6-output-prometheus-remote v0.3.1 // indirect
github.com/grafana/xk6-redis v0.2.0 // indirect
github.com/grafana/xk6-webcrypto v0.3.0 // indirect
github.com/grafana/xk6-websockets v0.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc // indirect
github.com/jhump/protoreflect v1.15.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mstoykov/envconfig v1.5.0 // indirect
github.com/mstoykov/k6-taskqueue-lib v0.1.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/r3labs/sse/v2 v2.10.0 // indirect
github.com/redis/go-redis/v9 v9.0.5 // indirect
github.com/spf13/cobra v1.4.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
Expand All @@ -66,14 +35,10 @@ require (
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
golang.org/x/crypto/x509roots/fallback v0.0.0-20240318092723-b91329d961d4 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/term v0.18.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
)

require (
Expand Down Expand Up @@ -101,10 +66,10 @@ require (
github.com/spf13/afero v1.9.5 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
gopkg.in/guregu/null.v3 v3.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 26647b9

Please sign in to comment.