aiorocket2.utils¶
Utility helpers used across the package.
The helpers are intentionally small and focused: id generation for idempotency and a simple exponential backoff helper used by network retry logic.
Functions
|
Asynchronously sleep using exponential backoff. |
Generate a simple idempotency identifier based on the current timestamp. |
|
|
Generate a simple idempotency identifier based on the current timestamp. |
- async aiorocket2.utils.backoff_sleep(attempt, base)[source]¶
Asynchronously sleep using exponential backoff.
- Parameters:
attempt (int) – 0-based attempt number. The delay grows as
base * 2**attempt.base (float) – Base delay in seconds for attempt 0.
- Return type:
None
Example:
await backoff_sleep(attempt=2, base=0.25) # sleeps 1.0s
- aiorocket2.utils.generate_idempotency_id()[source]¶
Generate a simple idempotency identifier based on the current timestamp.
- Returns:
A timestamp-based string suitable as a quick idempotency id.
- Return type:
str
Note
This function is intentionally simple. For production systems consider a stronger idempotency/nonce strategy (UUIDs or HMAC-based ids).
- aiorocket2.utils.gii()¶
Generate a simple idempotency identifier based on the current timestamp.
- Returns:
A timestamp-based string suitable as a quick idempotency id.
- Return type:
str
Note
This function is intentionally simple. For production systems consider a stronger idempotency/nonce strategy (UUIDs or HMAC-based ids).