MCPcopy
hub / github.com/Effect-TS/effect / makeBatched

Function makeBatched

packages/effect/src/internal/dataSource.ts:27–49  ·  view source on GitHub ↗
(
  run: (requests: RA.NonEmptyArray<A>) => Effect.Effect<void, never, R>
)

Source from the content-addressed store, hash-verified

25
26/** @internal */
27export const makeBatched = <A extends Request.Request<any, any>, R>(
28 run: (requests: RA.NonEmptyArray<A>) => Effect.Effect<void, never, R>
29): RequestResolver.RequestResolver<A, R> =>
30 new core.RequestResolverImpl<A, R>(
31 (requests) => {
32 if (requests.length > 1) {
33 return core.forEachSequentialDiscard(requests, (block) => {
34 const filtered = block.filter((_) => !_.state.completed).map((_) => _.request)
35 if (!RA.isNonEmptyArray(filtered)) {
36 return core.void
37 }
38 return invokeWithInterrupt(run(filtered), block)
39 })
40 } else if (requests.length === 1) {
41 const filtered = requests[0].filter((_) => !_.state.completed).map((_) => _.request)
42 if (!RA.isNonEmptyArray(filtered)) {
43 return core.void
44 }
45 return run(filtered)
46 }
47 return core.void
48 }
49 )
50
51/** @internal */
52export const around = dual<

Callers 4

fromFunctionFunction · 0.70
fromFunctionBatchedFunction · 0.70
fromEffectFunction · 0.70
fromEffectTaggedFunction · 0.70

Calls 3

invokeWithInterruptFunction · 0.85
runFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected