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

Add queuing strategy option for Stream.toReadableStream #2864

Merged

Conversation

mattrossman
Copy link
Contributor

@mattrossman mattrossman commented May 27, 2024

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Adds a "strategy" option to

  • Stream.toReadableStream
  • Stream.toReadableStreamEffect
  • Stream.toReadableStreamRuntime

This allows configuring the queuing strategy of the underlying ReadableStream.

// Default queuing strategy
stream.pipe(Stream.toReadableStream)

// Custom queuing strategies
stream.pipe(Stream.toReadableStream({ strategy: { highWaterMark: 2 } }))
stream.pipe(Stream.toReadableStream({ strategy: new CountQueuingStrategy({ highWaterMark: 2 }) }))

The name "strategy" was chosen to align with the Streams spec and TypeScript lib types.

References:

Note the diff for this PR shows many lines changed in toReadableStreamRuntime, these are mostly formatting changes incurred by the extra level of indentation from the expanded signature. The main real changes there are:

  • the ReadableStream constructor receives a second argument passed down via options?.strategy
  • the first argument of dual() has been changed from an arity of 2 to an isStream predicate matching other configurable stream functions

Related

Copy link

changeset-bot bot commented May 27, 2024

🦋 Changeset detected

Latest commit: f730c1a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
effect Minor
@effect/cli Major
@effect/experimental Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/platform Major
@effect/printer-ansi Major
@effect/printer Major
@effect/rpc-http Major
@effect/rpc Major
@effect/schema Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-node Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/sql Major
@effect/typeclass Major
@effect/vitest Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@tim-smart tim-smart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one small change.

.changeset/empty-islands-pump.md Outdated Show resolved Hide resolved
Co-authored-by: Tim <hello@timsmart.co>
@github-actions github-actions bot changed the base branch from main to next-minor May 28, 2024 12:32
@github-actions github-actions bot force-pushed the next-minor branch 2 times, most recently from 7a93c23 to e975f0e Compare May 28, 2024 23:20
@tim-smart tim-smart merged commit d629035 into Effect-TS:next-minor May 28, 2024
12 checks passed
@github-actions github-actions bot mentioned this pull request May 28, 2024
github-actions bot pushed a commit that referenced this pull request May 28, 2024
github-actions bot pushed a commit that referenced this pull request May 29, 2024
github-actions bot pushed a commit that referenced this pull request May 29, 2024
github-actions bot pushed a commit that referenced this pull request May 30, 2024
github-actions bot pushed a commit that referenced this pull request May 30, 2024
github-actions bot pushed a commit that referenced this pull request May 30, 2024
github-actions bot pushed a commit that referenced this pull request May 30, 2024
github-actions bot pushed a commit that referenced this pull request May 31, 2024
github-actions bot pushed a commit that referenced this pull request May 31, 2024
github-actions bot pushed a commit that referenced this pull request May 31, 2024
github-actions bot pushed a commit that referenced this pull request May 31, 2024
github-actions bot pushed a commit that referenced this pull request May 31, 2024
github-actions bot pushed a commit that referenced this pull request May 31, 2024
github-actions bot pushed a commit that referenced this pull request Jun 1, 2024
github-actions bot pushed a commit that referenced this pull request Jun 1, 2024
github-actions bot pushed a commit that referenced this pull request Jun 1, 2024
tim-smart added a commit that referenced this pull request Jun 5, 2024
tim-smart added a commit that referenced this pull request Jun 5, 2024
github-actions bot pushed a commit that referenced this pull request Jun 6, 2024
github-actions bot pushed a commit that referenced this pull request Jun 6, 2024
github-actions bot pushed a commit that referenced this pull request Jun 6, 2024
tim-smart added a commit that referenced this pull request Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Accept ReadableStream queuingStrategy in Stream.toReadableStream
2 participants