-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 to init a ReadableStream from a io.Reader #3740
Conversation
I think this is great 🚀 🚀 🚀 This is an idea I wanted to bring up here, but I'm not suggesting we should do it, consider it blocking, nor even arguing this is a good idea: I often find myself creating However, we ended up not needing generics at the time. I wonder if this idea would make sense in such a context, where for a type This is somewhat blurry in my head, but I keep thinking about it. Maybe this is something we could try in the future, although I'm not yet certain if it would have benefits beyond creating a contract for creating from and exporting as object given types (and I might be biased by Rust, where this would likely be the way to go in a lot of situations). I don't know, but if you have thoughts, I'd love to hear them 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
It's not related to the PR, but it's worth using branches in the grafana/k6
repository. That way, if needed, another maintainer could pick up the work and finish it.
Co-authored-by: Ivan <[email protected]>
}) | ||
} | ||
|
||
func underlyingSourceForReader(vu modules.VU, reader io.Reader) *sobek.Object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we miss a replacement here s/For/From/
"go.k6.io/k6/js/modulestest" | ||
) | ||
|
||
func TestNewReadableStreamForReader(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
What?
It exposes a mechanism from
streams
(Go) package to initialize a newReadableStream
from aio.Reader
:NewReadableStreamForReader(vu modules.VU, reader io.Reader) *goja.Object
Why?
Because this would makes it possible to reuse the
ReadableStream
implementation added inv0.51.0
from Go code, so other pieces in k6 (or any k6 extension) that have a Goio.Reader
and want to translate to aReadableStream
, usable from JS code, could it.Checklist
make lint
) and all checks pass.make tests
) and all tests pass.Related PR(s)/Issue(s)
N/A