MCPcopy Index your code
hub / github.com/Effect-TS/effect / fromPushPull

Function fromPushPull

packages/effect/src/internal/sink.ts:1444–1474  ·  view source on GitHub ↗
(
  push: (
    option: Option.Option<Chunk.Chunk<In>>
  ) => Effect.Effect<void, readonly [Either.Either<Z, E>, Chunk.Chunk<L>], R>
)

Source from the content-addressed store, hash-verified

1442 new SinkImpl(channel.unwrapScoped(pipe(push, Effect.map(fromPushPull))))
1443
1444const fromPushPull = <In, Z, E, L, R>(
1445 push: (
1446 option: Option.Option<Chunk.Chunk<In>>
1447 ) => Effect.Effect<void, readonly [Either.Either<Z, E>, Chunk.Chunk<L>], R>
1448): Channel.Channel<Chunk.Chunk<L>, Chunk.Chunk<In>, E, never, Z, unknown, R> =>
1449 core.readWith({
1450 onInput: (input: Chunk.Chunk<In>) =>
1451 channel.foldChannel(core.fromEffect(push(Option.some(input))), {
1452 onFailure: ([either, leftovers]) =>
1453 Either.match(either, {
1454 onLeft: (error) => pipe(core.write(leftovers), channel.zipRight(core.fail(error))),
1455 onRight: (z) => pipe(core.write(leftovers), channel.zipRight(core.succeedNow(z)))
1456 }),
1457 onSuccess: () => fromPushPull(push)
1458 }),
1459 onFailure: core.fail,
1460 onDone: () =>
1461 channel.foldChannel(core.fromEffect(push(Option.none())), {
1462 onFailure: ([either, leftovers]) =>
1463 Either.match(either, {
1464 onLeft: (error) => pipe(core.write(leftovers), channel.zipRight(core.fail(error))),
1465 onRight: (z) => pipe(core.write(leftovers), channel.zipRight(core.succeedNow(z)))
1466 }),
1467 onSuccess: () =>
1468 core.fromEffect(
1469 Effect.dieMessage(
1470 "BUG: Sink.fromPush - please report an issue at https://github.com/Effect-TS/effect/issues"
1471 )
1472 )
1473 })
1474 })
1475
1476/** @internal */
1477export const fromQueue = <In>(

Callers

nothing calls this directly

Calls 6

fromEffectMethod · 0.80
pipeFunction · 0.70
writeMethod · 0.65
failMethod · 0.65
dieMessageMethod · 0.65
pushFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…