mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-13 13:57:43 +02:00
29 lines
877 B
TypeScript
29 lines
877 B
TypeScript
import * as Effect from "effect/Effect";
|
|
import * as Semaphore from "effect/Semaphore";
|
|
|
|
// AWS permits only one ACCOUNT_UNUSED_ACCESS analyzer per account and Region.
|
|
// The test runner executes files concurrently in one process, so hold this
|
|
// semaphore across each suite's beforeAll → afterAll lifecycle.
|
|
const accessAnalyzerTestLock = Semaphore.makeUnsafe(1);
|
|
|
|
export const makeAccessAnalyzerTestLease = () => {
|
|
let held = false;
|
|
|
|
return {
|
|
acquire: Effect.uninterruptibleMask((restore) =>
|
|
restore(accessAnalyzerTestLock.take(1)).pipe(
|
|
Effect.tap(() =>
|
|
Effect.sync(() => {
|
|
held = true;
|
|
}),
|
|
),
|
|
Effect.asVoid,
|
|
),
|
|
),
|
|
release: Effect.suspend(() => {
|
|
if (!held) return Effect.void;
|
|
held = false;
|
|
return accessAnalyzerTestLock.release(1).pipe(Effect.asVoid);
|
|
}),
|
|
};
|
|
};
|