auth/session.pystarter · python
class SessionStore:
def __init__(self, ttl=3600):
self.ttl = ttl
self._store = {}
def issue(self, user_id):
token = secrets.token_hex(24)
self._store[token] = {
"uid": user_id,
"exp": time.time() + self.ttl,
}
return token
queue/worker.tsproof · typescript
export async function processBatch(jobs: Job[]) {
for (const job of jobs) {
try {
await handle(job);
markDone(job.id);
} catch (err) {
retry(job, { backoff: "exp" });
}
}
}