Skip to content

Restructure module stdio #520

Closed
Closed
@lann

Description

@lann

There have been a few recent issues and PRs around the ways stdio is managed for WASI modules:

The current state of the code is somewhat confusing, requiring coordination between the configuration passed in ExecutionContextConfiguration and the trigger executor implementation. Also, the options for stdio handling are limited to capturing to memory, capturing to files, and a follow flag that only works with the "capturing to memory" path.

There a few interrelated requirements to detangle here:

  • Some trigger executors need mandatory control over some of stdio (e.g. stdin/stdout for WAGI)
  • Some spin embedders want to intercept stdio (stdio in spin #438 (comment))
  • Where stdout/err aren't processed by a trigger executor or intercepted by an embedding, we (usually?) want the default behavior to log them to files and/or the console

I think we can restructure to simplify the code while maintaining these features:

  • Collapse the ExecutionContextConfiguration IO-related fields into a single io field typed like:

    struct IoDefaults {
      stdout: IoOutputBehavior,
      stderr: IoOutputBehavior,
    }
    enum IoOutputBehavior {
      Null,
      Log,
      Pipe(WritePipe),
    }
  • Update ExecutionContext::prepare_component's io arg to take a type something like:

    struct IoOverrides {
      stdin: Option<ReadPipe>,
      stdout: Option<WritePipe>,
      stderr: Option<WritePipe>,
    }
  • Update existing redirect_to_mem_buffer usage to use WritePipe::new_in_memory

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions