You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of our ongoing efforts to improve k6’s streaming capabilities, we propose adding support for the ReadableStream.pipeThrough method. This method is a key feature of the Streams API, allowing ReadableStream instances to be easily piped through TransformStream objects, creating a powerful and flexible way to process data streams in k6.
Background and prerequisites
Currently, k6 supports ReadableStream but lacks support for TransformStream and the pipeThrough method, limiting the ability to build complex streaming data processing pipelines. pipeThrough provides a convenient and declarative way to connect ReadableStream to TransformStream, greatly simplifying the code needed for stream transformations.
Implementing pipeThrough is tied to supporting TransformStream, as the two features are designed to work together.
Usage example
Once TransformStream and pipeThrough are implemented, the following example would be possible:
// Step 1: Create a readable stream (e.g., from a file or network response)constreadableStream=getReadableStreamSomehow();// Step 2: Define a simple transform stream to modify the dataconsttransformStream=newTransformStream({transform(chunk,controller){// Example transformation: Convert all text to uppercasecontroller.enqueue(chunk.toUpperCase());},});// Step 3: Pipe the readable stream through the transform streamreadableStream.pipeThrough(transformStream).getReader().read().then(({ done, value })=>{if(!done){console.log('Transformed Value:',value);}});
Suggested Solution (optional)
No response
Already existing or connected issues / PRs (optional)
Feature Description
Description
As part of our ongoing efforts to improve k6’s streaming capabilities, we propose adding support for the
ReadableStream.pipeThrough
method. This method is a key feature of the Streams API, allowing ReadableStream instances to be easily piped throughTransformStream
objects, creating a powerful and flexible way to process data streams in k6.Background and prerequisites
Currently, k6 supports
ReadableStream
but lacks support forTransformStream
and thepipeThrough
method, limiting the ability to build complex streaming data processing pipelines.pipeThrough
provides a convenient and declarative way to connectReadableStream
toTransformStream
, greatly simplifying the code needed for stream transformations.Implementing
pipeThrough
is tied to supportingTransformStream
, as the two features are designed to work together.Usage example
Once TransformStream and pipeThrough are implemented, the following example would be possible:
Suggested Solution (optional)
No response
Already existing or connected issues / PRs (optional)
depends on #3919
#3920
#2974
The text was updated successfully, but these errors were encountered: