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

Function asyncQueue

packages/effect/src/Channel.ts:459–473  ·  view source on GitHub ↗
(
  scope: Scope.Scope,
  f: (queue: Queue.Queue<A, E | Cause.Done>) => Effect.Effect<unknown, E, R | Scope.Scope>,
  options?: {
    readonly bufferSize?: number | undefined
    readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
  }
)

Source from the content-addressed store, hash-verified

457export const DefaultChunkSize: number = 4096
458
459const asyncQueue = <A, E = never, R = never>(
460 scope: Scope.Scope,
461 f: (queue: Queue.Queue<A, E | Cause.Done>) => Effect.Effect<unknown, E, R | Scope.Scope>,
462 options?: {
463 readonly bufferSize?: number | undefined
464 readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
465 }
466) =>
467 Queue.make<A, E | Cause.Done>({
468 capacity: options?.bufferSize,
469 strategy: options?.strategy
470 }).pipe(
471 Effect.tap((queue) => Scope.addFinalizer(scope, Queue.shutdown(queue))),
472 Effect.tap((queue) => Effect.forkIn(Scope.provide(f(queue), scope), scope))
473 )
474
475/**
476 * Creates a `Channel` that interacts with a callback function using a queue.

Callers 2

callbackFunction · 0.85
callbackArrayFunction · 0.85

Calls 6

addFinalizerMethod · 0.80
pipeMethod · 0.65
makeMethod · 0.65
fFunction · 0.50
shutdownMethod · 0.45
provideMethod · 0.45

Tested by

no test coverage detected