feat: limit accepted attachment work and add queue overload bench
Reject uploads with 429 at [uploads] max_unfinished_jobs, counted by the existing partial indexes in the membership block. Add the bench_queue profile, hypotheses H1-H9 and the fifth failure-stand API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -683,6 +683,23 @@ class FakeAttachmentJobRepository(
|
||||
) -> dataclasses.AttachmentJobDTO | None:
|
||||
return self._db.jobs.get(job_id)
|
||||
|
||||
async def count_unfinished(self, *, limit: int) -> int:
|
||||
groups = (
|
||||
[
|
||||
job
|
||||
for job in self._db.jobs.values()
|
||||
if job.state == AttachmentJobState.QUEUED
|
||||
and job.published_at is None
|
||||
],
|
||||
self._published(),
|
||||
[
|
||||
job
|
||||
for job in self._db.jobs.values()
|
||||
if job.state == AttachmentJobState.PROCESSING
|
||||
],
|
||||
)
|
||||
return sum(min(len(group), limit) for group in groups)
|
||||
|
||||
async def get_attachment_job(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user