Enabling Request Batching in a TypeScript Workflow for Deleting Layouts

How would I enable request batching in the following workflow?

export const deleteLayout = Effect.gen(function* () {
  const { siteID } = yield* schemaPathParams({
    siteID: Schema.String,
  });

  yield* Stream.runDrain(
    Stream.mergeAll(
      [
        Stream.mapEffect(Location.findBySite({ siteID }), Location.deleteOne),
        Stream.mapEffect(Module.findBySite({ siteID }), Module.deleteOne),
        Stream.mapEffect(
          Device.findBySite({ siteID }),
          Device.removeLocation,
          { concurrency: "unbounded" },
        ),
        Stream.mapEffect(Meter.findBySite({ siteID }), Meter.removeLocation, {
          concurrency: "unbounded",
        }),
      ],
      { concurrency: 2 },
    ),
  );
});


The Location.deleteOne and Module.deleteOne both support batching but my request is taking a very long time to complete which makes me wonder if they aren't being batched. Is it sufficient to add a .pipe(Effect.withRequestBatching(true)) here?
Was this page helpful?