Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
25 lines
625 B
Python
25 lines
625 B
Python
class JobStore:
|
|
"""In-memory job records, keyed by job id."""
|
|
|
|
def __init__(self):
|
|
self._jobs = {}
|
|
|
|
def put(self, job):
|
|
# upsert: the retry path saves updated records through here as well
|
|
self._jobs[job.id] = job
|
|
|
|
def get(self, job_id):
|
|
return self._jobs.get(job_id)
|
|
|
|
def delete(self, job_id):
|
|
return self._jobs.pop(job_id, None)
|
|
|
|
def __contains__(self, job_id):
|
|
return job_id in self._jobs
|
|
|
|
def __len__(self):
|
|
return len(self._jobs)
|
|
|
|
def count(self, status):
|
|
return sum(1 for job in self._jobs.values() if job.status == status)
|