IdAllocator¶
A simple in-process ID allocator for controlled ingestion contexts.
Used when: - database sequences are unavailable - ingestion is single-writer - deterministic ID assignment is required
API¶
Simple in-process ID allocator.
This utility provides monotonically increasing integer identifiers starting from a known baseline. It is intended for environments where database-managed sequences are unavailable or undesirable.
Typical use cases include: - SQLite or other lightweight databases without sequences - controlled, single-writer ingestion pipelines - deterministic ID assignment during bulk loads
This allocator is deliberately minimal and not safe for concurrent writers or multi-process use.
reserve(n)
¶
Reserve a contiguous block of identifiers.
This method advances the internal counter by n and returns
a range representing the reserved identifiers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
The number of identifiers to reserve. |
required |
Returns:
| Type | Description |
|---|---|
range
|
A range covering the reserved identifiers. |