Skip to content

Commit

Permalink
move queue limit to grants
Browse files Browse the repository at this point in the history
  • Loading branch information
InventivetalentDev committed Jan 21, 2025
1 parent e162f83 commit 950efb8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/models/v2/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,16 @@ async function v2SubmitGeneratorJob(req: GenerateV2Request, res: Response<V2Gene

if (req.client.hasUser()) {
const pendingByUser = await getClient().getPendingCountByUser(req.client.userId!)
if (pendingByUser > 5) { // TODO: configurable / client grant
const limit = req.client.getQueueLimit();
if (pendingByUser > limit) {
throw new GeneratorError('job_limit', "You have too many jobs in the queue", {
httpCode: 429,
source: ErrorSource.CLIENT
});
}
} else {
const pendingByIp = await getClient().getPendingCountByIp(req.client.ip!)
if (pendingByIp > 5) { // TODO: configurable / client grant
if (pendingByIp > 4) {
throw new GeneratorError('job_limit', "You have too many jobs in the queue", {
httpCode: 429,
source: ErrorSource.CLIENT
Expand Down

0 comments on commit 950efb8

Please sign in to comment.