gojs: refactors out gojs.Config type (#1240)

In order to support more configuration, we should stop using context as
it is getting gnarly.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2023-03-14 21:27:47 -07:00
committed by GitHub
parent 00c53d19a2
commit f24a3f49a4
22 changed files with 228 additions and 142 deletions

View File

@@ -6,24 +6,16 @@ import (
"math"
"github.com/tetratelabs/wazero/api"
"github.com/tetratelabs/wazero/internal/gojs/config"
"github.com/tetratelabs/wazero/internal/gojs/goos"
"github.com/tetratelabs/wazero/internal/gojs/values"
)
type WorkdirKey struct{}
func getWorkdir(ctx context.Context) string {
if wd, ok := ctx.Value(WorkdirKey{}).(string); ok {
return wd
}
return "/"
}
func NewState(ctx context.Context) *State {
func NewState(config *config.Config) *State {
return &State{
values: values.NewValues(),
valueGlobal: newJsGlobal(getRoundTripper(ctx)),
cwd: getWorkdir(ctx),
valueGlobal: newJsGlobal(config.Rt),
cwd: config.Workdir,
umask: 0o0022,
_nextCallbackTimeoutID: 1,
_scheduledTimeouts: map[uint32]chan bool{},