MCPcopy Create free account
hub / github.com/Effect-TS/effect / fromQueue

Function fromQueue

packages/effect/src/internal/stream.ts:3224–3245  ·  view source on GitHub ↗
(
  queue: Queue.Dequeue<A>,
  options?: {
    readonly maxChunkSize?: number | undefined
    readonly shutdown?: boolean | undefined
  }
)

Source from the content-addressed store, hash-verified

3222
3223/** @internal */
3224export const fromQueue = <A>(
3225 queue: Queue.Dequeue<A>,
3226 options?: {
3227 readonly maxChunkSize?: number | undefined
3228 readonly shutdown?: boolean | undefined
3229 }
3230): Stream.Stream<A> =>
3231 pipe(
3232 Queue.takeBetween(queue, 1, options?.maxChunkSize ?? DefaultChunkSize),
3233 Effect.catchAllCause((cause) =>
3234 pipe(
3235 Queue.isShutdown(queue),
3236 Effect.flatMap((isShutdown) =>
3237 isShutdown && Cause.isInterrupted(cause) ?
3238 pull.end() :
3239 pull.failCause(cause)
3240 )
3241 )
3242 ),
3243 repeatEffectChunkOption,
3244 options?.shutdown ? ensuring(Queue.shutdown(queue)) : identity
3245 )
3246
3247/** @internal */
3248export const fromTQueue = <A>(queue: TQueue.TDequeue<A>): Stream.Stream<A> =>

Callers 2

stream.tsFile · 0.70
fromPubSubFunction · 0.70

Calls 7

isInterruptedMethod · 0.80
failCauseMethod · 0.80
pipeFunction · 0.70
takeBetweenMethod · 0.65
endMethod · 0.65
isShutdownMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected