1import type * as Effect from "effect/Effect";
2import * as Semaphore from "effect/Semaphore";
3
4/**
5 * Dataplex throttles control-plane writes per project per minute. With the
6 * whole suite running in one process, more than a few concurrent Dataplex
7 * lifecycles exhaust the quota and time out, so every Dataplex test holds
8 * one of these slots for its whole body. A test's timeout includes the time
9 * it waits for a slot, so Dataplex tests use generous (15 min) timeouts.
10 */
11const slots = Semaphore.makeUnsafe(4);
12
13/** Run a Dataplex test body while holding one API-quota slot. */
14export const withDataplexSlot = <A, E, R>(
15 self: Effect.Effect<A, E, R>,
16): Effect.Effect<A, E, R> => slots.withPermits(1)(self);