Metadata-Version: 2.5
Name: iiapis
Version: 0.0.3
Summary: Exponential backoff delay sequences you can inspect and test.
Project-URL: Homepage, https://pypi.org/project/iiapis/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: backoff,delay,jitter,retry,schedule
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# iiapis

[English](#english) | 中文

可检视、可测试的指数退避延迟序列。

## 安装

```console
pip install iiapis
```

## 用法

```python
from iiapis import delay_for, delays

delays(5)                      # [0.5, 1.0, 2.0, 4.0, 8.0]
delays(6, n_base=1, n_max=5)   # [1, 2, 4, 5, 5, 5]
delay_for(3)                   # 2.0
delays(3, n_jitter=0.2)        # 每个值最多比原始延迟低 20%
```

## 说明

把退避算成数据而不是藏在 `sleep()` 里，方便打印、断言、交给调度器。`n_jitter` 是延迟的比例，按随机量在区间尾部扣减——没有它，同一刻失败的客户端会在同一刻一起重试。需要确定性输出时传 0。

## 许可证

MIT

---

<a id="english"></a>
## English

Exponential backoff delay sequences you can inspect and test.

## Install

```console
pip install iiapis
```

## Usage

```python
from iiapis import delay_for, delays

delays(5)                      # [0.5, 1.0, 2.0, 4.0, 8.0]
delays(6, n_base=1, n_max=5)   # [1, 2, 4, 5, 5, 5]
delay_for(3)                   # 2.0
delays(3, n_jitter=0.2)        # 每个值最多比原始延迟低 20%
```

## Notes

Backoff as data instead of a `sleep()` buried in a loop. `n_jitter` is a fraction of each delay, subtracted at random; without it every client that failed together retries together. Pass 0 for deterministic output.

## License

MIT
