| 247 | } |
| 248 | |
| 249 | func buildPluginConfig(input *Input, r *RuntimeExtismV1) extism.PluginConfig { |
| 250 | mc := wazero.NewModuleConfig(). |
| 251 | WithSysWalltime() |
| 252 | if input.Stdin != nil { |
| 253 | mc = mc.WithStdin(input.Stdin) |
| 254 | } |
| 255 | if input.Stdout != nil { |
| 256 | mc = mc.WithStdout(input.Stdout) |
| 257 | } |
| 258 | if input.Stderr != nil { |
| 259 | mc = mc.WithStderr(input.Stderr) |
| 260 | } |
| 261 | if len(input.Env) > 0 { |
| 262 | env := ParseEnv(input.Env) |
| 263 | for k, v := range env { |
| 264 | mc = mc.WithEnv(k, v) |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | config := extism.PluginConfig{ |
| 269 | ModuleConfig: mc, |
| 270 | RuntimeConfig: wazero.NewRuntimeConfigCompiler(). |
| 271 | WithCloseOnContextDone(true). |
| 272 | WithCompilationCache(r.CompilationCache), |
| 273 | EnableWasi: true, |
| 274 | EnableHttpResponseHeaders: true, |
| 275 | } |
| 276 | |
| 277 | return config |
| 278 | } |
| 279 | |
| 280 | func buildHostFunctions(hostFunctions map[string]extism.HostFunction, rc *RuntimeConfigExtismV1) ([]extism.HostFunction, error) { |
| 281 | result := make([]extism.HostFunction, len(rc.HostFunctions)) |