rust-py-rate-limit 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. rust_py_rate_limit-0.1.1/.github/workflows/CI.yml +75 -0
  2. rust_py_rate_limit-0.1.1/.github/workflows/release.yml +88 -0
  3. rust_py_rate_limit-0.1.1/.gitignore +12 -0
  4. rust_py_rate_limit-0.1.1/BACKLOG.md +566 -0
  5. rust_py_rate_limit-0.1.1/Cargo.lock +346 -0
  6. rust_py_rate_limit-0.1.1/Cargo.toml +27 -0
  7. rust_py_rate_limit-0.1.1/LICENSE +21 -0
  8. rust_py_rate_limit-0.1.1/PKG-INFO +351 -0
  9. rust_py_rate_limit-0.1.1/README.md +319 -0
  10. rust_py_rate_limit-0.1.1/examples/basic_usage.py +23 -0
  11. rust_py_rate_limit-0.1.1/examples/decorator_usage.py +35 -0
  12. rust_py_rate_limit-0.1.1/examples/django_example/README.md +47 -0
  13. rust_py_rate_limit-0.1.1/examples/fastapi_app.py +40 -0
  14. rust_py_rate_limit-0.1.1/pyproject.toml +51 -0
  15. rust_py_rate_limit-0.1.1/python/rust_py_rate_limit/__init__.py +66 -0
  16. rust_py_rate_limit-0.1.1/python/rust_py_rate_limit/decorators.py +52 -0
  17. rust_py_rate_limit-0.1.1/python/rust_py_rate_limit/django.py +67 -0
  18. rust_py_rate_limit-0.1.1/python/rust_py_rate_limit/exceptions.py +37 -0
  19. rust_py_rate_limit-0.1.1/python/rust_py_rate_limit/fastapi.py +72 -0
  20. rust_py_rate_limit-0.1.1/python/rust_py_rate_limit/flask.py +86 -0
  21. rust_py_rate_limit-0.1.1/src/entry.rs +28 -0
  22. rust_py_rate_limit-0.1.1/src/errors.rs +34 -0
  23. rust_py_rate_limit-0.1.1/src/fixed_window.rs +179 -0
  24. rust_py_rate_limit-0.1.1/src/lib.rs +36 -0
  25. rust_py_rate_limit-0.1.1/src/rate_limiter.rs +144 -0
  26. rust_py_rate_limit-0.1.1/src/sliding_window.rs +7 -0
  27. rust_py_rate_limit-0.1.1/src/stats.rs +53 -0
  28. rust_py_rate_limit-0.1.1/src/time_utils.rs +20 -0
  29. rust_py_rate_limit-0.1.1/src/token_bucket.rs +7 -0
  30. rust_py_rate_limit-0.1.1/tests/test_decorator.py +69 -0
  31. rust_py_rate_limit-0.1.1/tests/test_django.py +55 -0
  32. rust_py_rate_limit-0.1.1/tests/test_fastapi.py +53 -0
  33. rust_py_rate_limit-0.1.1/tests/test_fixed_window.py +83 -0
  34. rust_py_rate_limit-0.1.1/tests/test_remaining.py +43 -0
  35. rust_py_rate_limit-0.1.1/tests/test_reset.py +48 -0
  36. rust_py_rate_limit-0.1.1/tests/test_stats.py +68 -0
@@ -0,0 +1,75 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ rust-tests:
14
+ name: cargo test
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: dtolnay/rust-toolchain@stable
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.12"
22
+ - uses: Swatinem/rust-cache@v2
23
+ - name: cargo fmt
24
+ run: cargo fmt --all -- --check
25
+ - name: cargo clippy
26
+ run: cargo clippy --all-targets -- -D warnings
27
+ - name: cargo test
28
+ run: cargo test
29
+
30
+ python-tests:
31
+ name: pytest (${{ matrix.python-version }})
32
+ runs-on: ubuntu-latest
33
+ strategy:
34
+ fail-fast: false
35
+ matrix:
36
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+ - uses: dtolnay/rust-toolchain@stable
40
+ - uses: actions/setup-python@v5
41
+ with:
42
+ python-version: ${{ matrix.python-version }}
43
+ - uses: Swatinem/rust-cache@v2
44
+ - name: Install package + dev dependencies
45
+ # `pip install` uses the maturin build backend to compile and install
46
+ # the extension. Unlike `maturin develop`, it does not require an active
47
+ # virtualenv, so it works directly against the runner's Python.
48
+ run: |
49
+ python -m pip install --upgrade pip
50
+ pip install ".[dev]"
51
+ - name: Run pytest
52
+ run: pytest -q
53
+
54
+ build-wheels:
55
+ name: build wheels (${{ matrix.os }})
56
+ runs-on: ${{ matrix.os }}
57
+ strategy:
58
+ fail-fast: false
59
+ matrix:
60
+ os: [ubuntu-latest, macos-latest, windows-latest]
61
+ steps:
62
+ - uses: actions/checkout@v4
63
+ - uses: actions/setup-python@v5
64
+ with:
65
+ python-version: "3.12"
66
+ - name: Build wheels
67
+ uses: PyO3/maturin-action@v1
68
+ with:
69
+ command: build
70
+ args: --release --out dist
71
+ - name: Upload wheels
72
+ uses: actions/upload-artifact@v4
73
+ with:
74
+ name: wheels-${{ matrix.os }}
75
+ path: dist
@@ -0,0 +1,88 @@
1
+ name: Release
2
+
3
+ # Builds wheels + sdist for all platforms and publishes them.
4
+ #
5
+ # * Pushing a tag like `v0.1.0` publishes to PyPI.
6
+ # * Manual runs (workflow_dispatch) publish to TestPyPI, so you can validate
7
+ # the release flow before cutting a real tag.
8
+ #
9
+ # Publishing uses PyPI "trusted publishing" (OIDC); configure the publisher in
10
+ # your PyPI / TestPyPI project settings — no API tokens needed.
11
+
12
+ on:
13
+ push:
14
+ tags: ["v*"]
15
+ workflow_dispatch:
16
+
17
+ permissions:
18
+ contents: read
19
+
20
+ jobs:
21
+ build:
22
+ name: build wheels (${{ matrix.os }})
23
+ runs-on: ${{ matrix.os }}
24
+ strategy:
25
+ fail-fast: false
26
+ matrix:
27
+ os: [ubuntu-latest, macos-latest, windows-latest]
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: actions/setup-python@v5
31
+ with:
32
+ python-version: "3.12"
33
+ - name: Build wheels
34
+ uses: PyO3/maturin-action@v1
35
+ with:
36
+ command: build
37
+ args: --release --out dist
38
+ - uses: actions/upload-artifact@v4
39
+ with:
40
+ name: wheels-${{ matrix.os }}
41
+ path: dist
42
+
43
+ sdist:
44
+ name: build sdist
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - name: Build sdist
49
+ uses: PyO3/maturin-action@v1
50
+ with:
51
+ command: sdist
52
+ args: --out dist
53
+ - uses: actions/upload-artifact@v4
54
+ with:
55
+ name: sdist
56
+ path: dist
57
+
58
+ publish-testpypi:
59
+ name: Publish to TestPyPI
60
+ if: github.event_name == 'workflow_dispatch'
61
+ needs: [build, sdist]
62
+ runs-on: ubuntu-latest
63
+ environment: testpypi
64
+ permissions:
65
+ id-token: write
66
+ steps:
67
+ - uses: actions/download-artifact@v4
68
+ with:
69
+ path: dist
70
+ merge-multiple: true
71
+ - uses: pypa/gh-action-pypi-publish@release/v1
72
+ with:
73
+ repository-url: https://test.pypi.org/legacy/
74
+
75
+ publish-pypi:
76
+ name: Publish to PyPI
77
+ if: startsWith(github.ref, 'refs/tags/')
78
+ needs: [build, sdist]
79
+ runs-on: ubuntu-latest
80
+ environment: pypi
81
+ permissions:
82
+ id-token: write
83
+ steps:
84
+ - uses: actions/download-artifact@v4
85
+ with:
86
+ path: dist
87
+ merge-multiple: true
88
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,12 @@
1
+ /target
2
+ /dist
3
+ /wheels
4
+
5
+ # Python
6
+ .venv/
7
+ __pycache__/
8
+ *.py[cod]
9
+ *.so
10
+ .pytest_cache/
11
+ *.egg-info/
12
+ build/