@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, 04:45 UTC

main
ts 17 lines 557 Bytes
Raw
1 import { HttpError } from './errors.ts';
2
3 // Isolate-wide resource counters contain no request data or I/O promises. Rate
4 // limiting controls traffic; these counters additionally bound simultaneous buffers.
5 export class Admission {
6 private stores = 0;
7 private reads = 0;
8 acquire(store: boolean): () => void {
9 if (store ? this.stores >= 2 : this.reads >= 4) throw new HttpError(503, 'concurrency_limit');
10 if (store) this.stores++;
11 else this.reads++;
12 return () => {
13 if (store) this.stores--;
14 else this.reads--;
15 };
16 }
17 }