feat(job-array-one-based-index): idgen allocates ordinary IDs only (task 9.1)
idgen() now accepts only a size of 1 (anything else: -EINVAL, context unchanged) and refuses an exhausted 20-bit sequence with -EOVERFLOW instead of spilling into the timestamp (also after idgen_array has taken the last block). Arrays come only from idgen_array; every caller of idgen/GenerateJobID passes 1. The old multi-element test loop moves to idgen_array with 1-based assertions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d3b12159a4
commit
63eaea215a
4 changed files with 110 additions and 26 deletions
|
|
@ -17,9 +17,16 @@ typedef struct {
|
|||
} idgen_ctx_t;
|
||||
|
||||
extern int idgen_ctx_init(idgen_ctx_t*);
|
||||
extern int idgen(idgen_ctx_t*, size_t, size_t, size_t, uint64_t*);
|
||||
extern void idgen_ctx_fini(idgen_ctx_t*);
|
||||
|
||||
/* Ordinary (non-array) job ID. arraySize must be 1; array jobs are
|
||||
* allocated with idgen_array(). On success *pidx is an untagged ID and 1 is
|
||||
* returned. -EINVAL for bad args or arraySize != 1; -EOVERFLOW if the
|
||||
* sequence field is exhausted for the current second (the context is left
|
||||
* unchanged). */
|
||||
extern int idgen(idgen_ctx_t* ctx, size_t clusterId, size_t apiserverId,
|
||||
size_t arraySize, uint64_t* pidx);
|
||||
|
||||
/* First element ID of a new n-element array, numbered from 1.
|
||||
* 1 <= n <= MAX_ARRAY_IDX (32767). On success *first = MAKE_JOBID(c, a, ts,
|
||||
* TAG_JOB_ARRAY, (block << 15) | 1), the context is advanced past the whole
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue