Skip to content

Commit

Permalink
default to unbounded buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Jul 18, 2024
1 parent f464e69 commit b858e05
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
6 changes: 0 additions & 6 deletions .changeset/beige-rules-argue.md

This file was deleted.

6 changes: 3 additions & 3 deletions .changeset/forty-beers-refuse.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ You can use the `emit` helper to emit values to the stream. You can also use
the `emit` helper to signal the end of the stream by using apis such as
`emit.end` or `emit.fail`.

By default it uses a buffer size of 4096 and a dropping strategy to prevent
memory issues. You can customize the buffer size and strategy by passing an
object as the second argument with the `bufferSize` and `strategy` fields.
By default it uses an "unbounded" buffer size.
You can customize the buffer size and strategy by passing an object as the
second argument with the `bufferSize` and `strategy` fields.

```ts
import { Effect, Stream } from "effect";
Expand Down
6 changes: 3 additions & 3 deletions packages/effect/src/Stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ export const asyncEffect: <A, E = never, R = never>(
* You can also use the `emit` helper to signal the end of the stream by
* using apis such as `emit.end` or `emit.fail`.
*
* By default it uses a buffer size of 4096 and a dropping strategy to prevent
* memory issues. You can customize the buffer size and strategy by passing an
* object as the second argument with the `bufferSize` and `strategy` fields.
* By default it uses an "unbounded" buffer size.
* You can customize the buffer size and strategy by passing an object as the
* second argument with the `bufferSize` and `strategy` fields.
*
* @example
* import { Effect, Stream } from "effect"
Expand Down
6 changes: 3 additions & 3 deletions packages/effect/src/internal/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,14 @@ const queueFromBufferOptionsPush = <A>(
readonly strategy?: "dropping" | "sliding" | undefined
} | undefined
): Effect.Effect<Queue.Queue<A | typeof emit.pushEOF>> => {
if (options?.bufferSize === "unbounded") {
if (options?.bufferSize === "unbounded" || (options?.bufferSize === undefined && options?.strategy === undefined)) {
return Queue.unbounded()
}
switch (options?.strategy) {
case "sliding":
return Queue.sliding(options?.bufferSize ?? DefaultChunkSize)
return Queue.sliding(options.bufferSize ?? 16)
default:
return Queue.dropping(options?.bufferSize ?? DefaultChunkSize)
return Queue.dropping(options?.bufferSize ?? 16)
}
}

Expand Down

0 comments on commit b858e05

Please sign in to comment.