wasi-module-sdk-go/executor.go

28 lines
511 B
Go
Raw Normal View History

2023-05-08 13:21:31 +00:00
package sdk
import (
"context"
2023-08-15 20:10:30 +00:00
"log/slog"
2023-05-08 13:21:31 +00:00
)
func NewExecutor(repoRoot, outDir, binDir string) Executor {
return Executor{
logger: slog.New(NewWASIHandler()),
repoRoot: repoRoot,
outDir: outDir,
binDir: binDir,
}
}
type Executor struct {
logger *slog.Logger
repoRoot string
outDir string
binDir string
}
2023-09-05 20:06:42 +00:00
func (e Executor) Run(ctx context.Context, m Module) error {
2023-05-24 20:11:05 +00:00
execCtx := newWasiExecutionContext(ctx, e.logger, m, e.repoRoot, e.binDir, e.outDir)
2023-09-05 20:06:42 +00:00
return m.Execute(execCtx)
2023-05-08 13:21:31 +00:00
}