Skip to content

Commit 1efcde6

Browse files
committed
Admin endpoint to set concurrency burst factor
Example cURL call using an admin user PAT (replace with a real one): ```sh curl -X PUT https://cloud.trigger.dev/admin/api/v1/environments/<environmentId>/burst-factor \ -H "Authorization: Bearer tr_pat_1234" \ -H "Content-Type: application/json" \ -d '{"burstFactor": 1.5}' ```
1 parent 9a988ab commit 1efcde6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { type ActionFunctionArgs, json } from "@remix-run/server-runtime";
2+
import { z } from "zod";
3+
import { prisma } from "~/db.server";
4+
import { requireAdminApiRequest } from "~/services/personalAccessToken.server";
5+
import { updateEnvConcurrencyLimits } from "~/v3/runQueue.server";
6+
7+
const ParamsSchema = z.object({
8+
environmentId: z.string(),
9+
});
10+
11+
const RequestBodySchema = z.object({
12+
burstFactor: z.number().positive(),
13+
});
14+
15+
export async function action({ request, params }: ActionFunctionArgs) {
16+
await requireAdminApiRequest(request);
17+
18+
const { environmentId } = ParamsSchema.parse(params);
19+
const body = RequestBodySchema.parse(await request.json());
20+
21+
const environment = await prisma.runtimeEnvironment.update({
22+
where: { id: environmentId },
23+
data: { concurrencyLimitBurstFactor: body.burstFactor },
24+
include: { organization: true, project: true },
25+
});
26+
27+
await updateEnvConcurrencyLimits(environment);
28+
29+
return json({ success: true });
30+
}

0 commit comments

Comments
 (0)