-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
123 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package js | ||
|
||
import ( | ||
"go.k6.io/k6/js/modules" | ||
"go.k6.io/k6/js/modules/k6" | ||
"go.k6.io/k6/js/modules/k6/crypto" | ||
"go.k6.io/k6/js/modules/k6/crypto/x509" | ||
"go.k6.io/k6/js/modules/k6/data" | ||
"go.k6.io/k6/js/modules/k6/encoding" | ||
"go.k6.io/k6/js/modules/k6/execution" | ||
"go.k6.io/k6/js/modules/k6/grpc" | ||
"go.k6.io/k6/js/modules/k6/html" | ||
"go.k6.io/k6/js/modules/k6/http" | ||
"go.k6.io/k6/js/modules/k6/metrics" | ||
"go.k6.io/k6/js/modules/k6/ws" | ||
|
||
"github.com/grafana/xk6-redis/redis" | ||
"github.com/grafana/xk6-timers/timers" | ||
expws "github.com/grafana/xk6-websockets/websockets" | ||
) | ||
|
||
func getInternalJSModules() map[string]interface{} { | ||
return map[string]interface{}{ | ||
"k6": k6.New(), | ||
"k6/crypto": crypto.New(), | ||
"k6/crypto/x509": x509.New(), | ||
"k6/data": data.New(), | ||
"k6/encoding": encoding.New(), | ||
"k6/execution": execution.New(), | ||
"k6/experimental/redis": redis.New(), | ||
"k6/experimental/websockets": &expws.RootModule{}, | ||
"k6/experimental/timers": timers.New(), | ||
"k6/net/grpc": grpc.New(), | ||
"k6/html": html.New(), | ||
"k6/http": http.New(), | ||
"k6/metrics": metrics.New(), | ||
"k6/ws": ws.New(), | ||
} | ||
} | ||
|
||
func getJSModules() map[string]interface{} { | ||
result := getInternalJSModules() | ||
external := modules.GetJSModules() | ||
|
||
// external is always prefixed with `k6/x` | ||
for k, v := range external { | ||
result[k] = v | ||
} | ||
|
||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package js | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/dop251/goja" | ||
"go.k6.io/k6/js/common" | ||
"go.k6.io/k6/js/eventloop" | ||
"go.k6.io/k6/lib" | ||
) | ||
|
||
type moduleVUImpl struct { | ||
ctx context.Context | ||
initEnv *common.InitEnvironment | ||
state *lib.State | ||
runtime *goja.Runtime | ||
eventLoop *eventloop.EventLoop | ||
} | ||
|
||
func (m *moduleVUImpl) Context() context.Context { | ||
return m.ctx | ||
} | ||
|
||
func (m *moduleVUImpl) InitEnv() *common.InitEnvironment { | ||
return m.initEnv | ||
} | ||
|
||
func (m *moduleVUImpl) State() *lib.State { | ||
return m.state | ||
} | ||
|
||
func (m *moduleVUImpl) Runtime() *goja.Runtime { | ||
return m.runtime | ||
} | ||
|
||
func (m *moduleVUImpl) RegisterCallback() func(func() error) { | ||
return m.eventLoop.RegisterCallback() | ||
} |
Oops, something went wrong.