Skip to content

Commit

Permalink
Merge pull request #125 from thorpelawrence-yoti/wazero-runtime-config
Browse files Browse the repository at this point in the history
add option to set wazero RuntimeConfig
  • Loading branch information
jerbob92 authored Jan 16, 2024
2 parents 56aa1c7 + 6f6d983 commit b524299
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions webassembly/webassembly.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ type worker struct {
}

type Config struct {
MinIdle int
MaxIdle int
MaxTotal int
WASM []byte
FSConfig wazero.FSConfig
Stdout io.Writer
Stderr io.Writer
RandomSource io.Reader
ReuseWorkers bool // WebAssembly runtime by default doesn't use workers because creating new instances is cheap.
MinIdle int
MaxIdle int
MaxTotal int
WASM []byte
FSConfig wazero.FSConfig
RuntimeConfig wazero.RuntimeConfig
Stdout io.Writer
Stderr io.Writer
RandomSource io.Reader
ReuseWorkers bool // WebAssembly runtime by default doesn't use workers because creating new instances is cheap.
}

type pdfiumPool struct {
Expand Down Expand Up @@ -106,9 +107,14 @@ func Init(config Config) (pdfium.Pool, error) {
config.RandomSource = rand.Reader
}

if config.RuntimeConfig == nil {
config.RuntimeConfig = wazero.NewRuntimeConfig()
}

poolContext := context.WithValue(context.Background(), experimental.FunctionListenerFactoryKey{}, logging.NewLoggingListenerFactory(os.Stdout))
poolContext = context.Background()
runtime := wazero.NewRuntimeWithConfig(poolContext, wazero.NewRuntimeConfig())

runtime := wazero.NewRuntimeWithConfig(poolContext, config.RuntimeConfig)

// Import WASI features.
if _, err := wasi_snapshot_preview1.Instantiate(poolContext, runtime); err != nil {
Expand Down

0 comments on commit b524299

Please sign in to comment.