Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fd_sync for stdout/stderr writers via optional interface #2359

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robherley
Copy link

As far as I know, when an arbitrary io.Writer is passed for the module's stdout/stderr, it's not possible to hook into fd_sync when it is called on the respective file descriptor.

I've extended writerFile struct to attempt to call a Sync method on the inner writer interface, if it passes the type assertion.

My use case is as follows:

  1. For the module's WithStdout, I'm passing in a wrapper http.ResponseWriter.
  2. When the guest calls os.Stdout.Sync() I want to invoke http.Flusher.Flush() on the guest.

As long as the writer decides to implement this simple interface:

type syncer interface {
	Sync() error
}

The host can hook into whenever the client flushes the fd.


Also, thanks for this amazing project, I've been meaning to dive into wazero ever since I saw Takeshi's talk at GopherCon '22 in person 😄

Signed-off-by: Rob Herley <[email protected]>
@robherley robherley requested a review from mathetake as a code owner January 12, 2025 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant