ACUC: Dynamic Limits (FIR-1641) (#1434)

* extend acuc definition

* kill plan

* stuff

* stupid tests

* feat: better acuc

* feat(acuc): mock ACUC when not using db auth
This commit is contained in:
Gergő Móricz
2025-04-10 18:49:23 +02:00
committed by GitHub
parent f2865f6699
commit 6a10f0689d
43 changed files with 611 additions and 985 deletions
@@ -1,13 +1,10 @@
import { authenticateUser } from "../auth";
import {
ConcurrencyCheckParams,
ConcurrencyCheckResponse,
RequestWithAuth,
} from "./types";
import { RateLimiterMode, PlanType } from "../../types";
import { Response } from "express";
import { redisConnection } from "../../services/queue-service";
import { getConcurrencyLimitMax } from "../../services/rate-limiter";
// Basically just middleware and error wrapping
export async function concurrencyCheckController(
@@ -22,14 +19,9 @@ export async function concurrencyCheckController(
Infinity,
);
const maxConcurrency = getConcurrencyLimitMax(
req.auth.plan as PlanType,
req.auth.team_id,
);
return res.status(200).json({
success: true,
concurrency: activeJobsOfTeam.length,
maxConcurrency: maxConcurrency,
maxConcurrency: req.acuc.concurrency,
});
}