Files
leleka/scripts/e2e/codex/tasks/debuglog-sched/seed/sched/ids.py
T

16 lines
395 B
Python

"""Job id generation."""
ID_BITS = 12 # three hex digits keep ids short enough to read out on a support call
ID_MASK = (1 << ID_BITS) - 1
class IdGenerator:
"""Hands out ids like j-0a3, one per accepted job."""
def __init__(self, start=0):
self._seq = start & ID_MASK
def next_id(self):
self._seq = (self._seq + 1) & ID_MASK
return "j-%03x" % self._seq