@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 32 lines 1.08 KB
Raw
1 import * as Effect from "effect/Effect";
2 import * as Semaphore from "effect/Semaphore";
3
4 // Telemetry evaluation is an account-wide singleton, and AWS also rejects
5 // concurrently managed rules with identical configurations even when their
6 // names differ. alchemy-test runs files concurrently in one process, so hold
7 // this lease from each file's root beforeAll through its root afterAll. This
8 // keeps setup, lifecycle assertions, and capture-and-restore cleanup atomic
9 // across the ObservabilityAdmin service tests.
10 const observabilityAdminTestLock = Semaphore.makeUnsafe(1);
11
12 export const makeObservabilityAdminTestLease = () => {
13 let held = false;
14
15 return {
16 acquire: Effect.uninterruptibleMask((restore) =>
17 restore(observabilityAdminTestLock.take(1)).pipe(
18 Effect.tap(() =>
19 Effect.sync(() => {
20 held = true;
21 }),
22 ),
23 Effect.asVoid,
24 ),
25 ),
26 release: Effect.suspend(() => {
27 if (!held) return Effect.void;
28 held = false;
29 return observabilityAdminTestLock.release(1).pipe(Effect.asVoid);
30 }),
31 };
32 };