swarmauri_middleware_bulkhead 0.8.0.dev3__tar.gz → 0.8.0.dev31__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.
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_middleware_bulkhead
3
+ Version: 0.8.0.dev31
4
+ Summary: Bulkhead middleware implementation for Swarmauri
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,sdk,standards,middleware,bulkhead
8
+ Author: Jacob Stewart
9
+ Author-email: jacob@swarmauri.com
10
+ Requires-Python: >=3.10,<3.13
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Development Status :: 3 - Alpha
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Requires-Dist: fastapi
22
+ Requires-Dist: swarmauri_base
23
+ Requires-Dist: swarmauri_core
24
+ Requires-Dist: swarmauri_standard
25
+ Description-Content-Type: text/markdown
26
+
27
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
28
+
29
+ <p align="center">
30
+ <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
31
+ <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_bulkhead" alt="PyPI - Downloads"/>
32
+ </a>
33
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_bulkhead/">
34
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_bulkhead.svg"/>
35
+ </a>
36
+ <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
37
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_bulkhead" alt="PyPI - Python Version"/>
38
+ </a>
39
+ <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
40
+ <img src="https://img.shields.io/pypi/l/swarmauri_middleware_bulkhead" alt="PyPI - License"/>
41
+ </a>
42
+ <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
43
+ <img src="https://img.shields.io/pypi/v/swarmauri_middleware_bulkhead?label=swarmauri_middleware_bulkhead&color=green" alt="PyPI - swarmauri_middleware_bulkhead"/>
44
+ </a>
45
+ </p>
46
+
47
+ ---
48
+
49
+ # Swarmauri Middleware Bulkhead
50
+
51
+ Concurrency isolation middleware for FastAPI applications. Limit the number of simultaneous requests to protect resources from overload and ensure reliable service operation.
52
+
53
+ ## Features
54
+
55
+ - **Concurrency control** restricts the number of in-flight requests using an `asyncio.Semaphore`.
56
+ - **Configurable limits** let you tune `max_concurrency` (default: 10) to match service capacity.
57
+ - **Fail-fast validation** guards against non-positive concurrency limits at initialization.
58
+ - **Structured logging** surfaces request flow and failure details for easier diagnostics.
59
+ - **FastAPI compatibility** enables seamless integration into ASGI middleware stacks.
60
+
61
+ ## Installation
62
+
63
+ Choose the tool that matches your workflow:
64
+
65
+ ```bash
66
+ # pip
67
+ pip install swarmauri_middleware_bulkhead
68
+
69
+ # Poetry
70
+ poetry add swarmauri_middleware_bulkhead
71
+
72
+ # uv
73
+ uv add swarmauri_middleware_bulkhead
74
+ ```
75
+
76
+ ## Quickstart
77
+
78
+ The middleware wraps a `call_next` handler and ensures that no more than `max_concurrency` requests execute at once. Run the example below with `python quickstart.py` to see the concurrency ceiling in action.
79
+
80
+ ```python
81
+ import asyncio
82
+
83
+ from fastapi import Request
84
+
85
+ from swarmauri_middleware_bulkhead import BulkheadMiddleware
86
+
87
+
88
+ async def main() -> None:
89
+ bulkhead = BulkheadMiddleware(max_concurrency=2)
90
+ active_requests = 0
91
+ peak_active_requests = 0
92
+ lock = asyncio.Lock()
93
+
94
+ async def call_next(request: Request):
95
+ nonlocal active_requests, peak_active_requests
96
+ async with lock:
97
+ active_requests += 1
98
+ peak_active_requests = max(peak_active_requests, active_requests)
99
+
100
+ try:
101
+ await asyncio.sleep(0.05)
102
+ return {"path": request.scope.get("path"), "handled": True}
103
+ finally:
104
+ async with lock:
105
+ active_requests -= 1
106
+
107
+ async def simulate_request(idx: int):
108
+ request = Request(scope={"type": "http", "path": f"/task/{idx}"})
109
+ return await bulkhead.dispatch(request, call_next)
110
+
111
+ responses = await asyncio.gather(*(simulate_request(i) for i in range(5)))
112
+
113
+ assert peak_active_requests <= bulkhead.max_concurrency
114
+ print("Peak concurrent requests:", peak_active_requests)
115
+ print("Responses:", responses)
116
+
117
+
118
+ if __name__ == "__main__":
119
+ asyncio.run(main())
120
+ ```
121
+
122
+ ## Want to help?
123
+
124
+ If you want to contribute to swarmauri-sdk, read up on our
125
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
126
+ that will help you get started.
127
+
@@ -0,0 +1,100 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_bulkhead" alt="PyPI - Downloads"/>
6
+ </a>
7
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_bulkhead/">
8
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_bulkhead.svg"/>
9
+ </a>
10
+ <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
11
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_bulkhead" alt="PyPI - Python Version"/>
12
+ </a>
13
+ <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
14
+ <img src="https://img.shields.io/pypi/l/swarmauri_middleware_bulkhead" alt="PyPI - License"/>
15
+ </a>
16
+ <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
17
+ <img src="https://img.shields.io/pypi/v/swarmauri_middleware_bulkhead?label=swarmauri_middleware_bulkhead&color=green" alt="PyPI - swarmauri_middleware_bulkhead"/>
18
+ </a>
19
+ </p>
20
+
21
+ ---
22
+
23
+ # Swarmauri Middleware Bulkhead
24
+
25
+ Concurrency isolation middleware for FastAPI applications. Limit the number of simultaneous requests to protect resources from overload and ensure reliable service operation.
26
+
27
+ ## Features
28
+
29
+ - **Concurrency control** restricts the number of in-flight requests using an `asyncio.Semaphore`.
30
+ - **Configurable limits** let you tune `max_concurrency` (default: 10) to match service capacity.
31
+ - **Fail-fast validation** guards against non-positive concurrency limits at initialization.
32
+ - **Structured logging** surfaces request flow and failure details for easier diagnostics.
33
+ - **FastAPI compatibility** enables seamless integration into ASGI middleware stacks.
34
+
35
+ ## Installation
36
+
37
+ Choose the tool that matches your workflow:
38
+
39
+ ```bash
40
+ # pip
41
+ pip install swarmauri_middleware_bulkhead
42
+
43
+ # Poetry
44
+ poetry add swarmauri_middleware_bulkhead
45
+
46
+ # uv
47
+ uv add swarmauri_middleware_bulkhead
48
+ ```
49
+
50
+ ## Quickstart
51
+
52
+ The middleware wraps a `call_next` handler and ensures that no more than `max_concurrency` requests execute at once. Run the example below with `python quickstart.py` to see the concurrency ceiling in action.
53
+
54
+ ```python
55
+ import asyncio
56
+
57
+ from fastapi import Request
58
+
59
+ from swarmauri_middleware_bulkhead import BulkheadMiddleware
60
+
61
+
62
+ async def main() -> None:
63
+ bulkhead = BulkheadMiddleware(max_concurrency=2)
64
+ active_requests = 0
65
+ peak_active_requests = 0
66
+ lock = asyncio.Lock()
67
+
68
+ async def call_next(request: Request):
69
+ nonlocal active_requests, peak_active_requests
70
+ async with lock:
71
+ active_requests += 1
72
+ peak_active_requests = max(peak_active_requests, active_requests)
73
+
74
+ try:
75
+ await asyncio.sleep(0.05)
76
+ return {"path": request.scope.get("path"), "handled": True}
77
+ finally:
78
+ async with lock:
79
+ active_requests -= 1
80
+
81
+ async def simulate_request(idx: int):
82
+ request = Request(scope={"type": "http", "path": f"/task/{idx}"})
83
+ return await bulkhead.dispatch(request, call_next)
84
+
85
+ responses = await asyncio.gather(*(simulate_request(i) for i in range(5)))
86
+
87
+ assert peak_active_requests <= bulkhead.max_concurrency
88
+ print("Peak concurrent requests:", peak_active_requests)
89
+ print("Responses:", responses)
90
+
91
+
92
+ if __name__ == "__main__":
93
+ asyncio.run(main())
94
+ ```
95
+
96
+ ## Want to help?
97
+
98
+ If you want to contribute to swarmauri-sdk, read up on our
99
+ [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
100
+ that will help you get started.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_middleware_bulkhead"
3
- version = "0.8.0.dev3"
3
+ version = "0.8.0.dev31"
4
4
  description = "Bulkhead middleware implementation for Swarmauri"
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -13,7 +13,10 @@ classifiers = [
13
13
  "Programming Language :: Python :: 3.11",
14
14
  "Programming Language :: Python :: 3.12",
15
15
  "Programming Language :: Python :: 3.13",
16
- "Development Status :: 3 - Alpha"
16
+ "Development Status :: 3 - Alpha",
17
+ "Programming Language :: Python",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only"
17
20
  ]
18
21
  authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
19
22
  dependencies = [
@@ -22,6 +25,13 @@ dependencies = [
22
25
  "swarmauri_base",
23
26
  "swarmauri_standard",
24
27
  ]
28
+ keywords = [
29
+ 'swarmauri',
30
+ 'sdk',
31
+ 'standards',
32
+ 'middleware',
33
+ 'bulkhead',
34
+ ]
25
35
 
26
36
  [tool.uv.sources]
27
37
  swarmauri_core = { workspace = true }
@@ -40,6 +50,7 @@ markers = [
40
50
  "xfail: Expected failures",
41
51
  "acceptance: Acceptance tests",
42
52
  "perf: Performance tests that measure execution time and resource usage",
53
+ "example: Example usage tests",
43
54
  ]
44
55
  timeout = 300
45
56
  log_cli = true
@@ -1,63 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_middleware_bulkhead
3
- Version: 0.8.0.dev3
4
- Summary: Bulkhead middleware implementation for Swarmauri
5
- License: Apache-2.0
6
- Author: Jacob Stewart
7
- Author-email: jacob@swarmauri.com
8
- Requires-Python: >=3.10,<3.13
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Natural Language :: English
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Development Status :: 3 - Alpha
16
- Requires-Dist: fastapi
17
- Requires-Dist: swarmauri_base
18
- Requires-Dist: swarmauri_core
19
- Requires-Dist: swarmauri_standard
20
- Description-Content-Type: text/markdown
21
-
22
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
23
-
24
- <p align="center">
25
- <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
26
- <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_bulkhead" alt="PyPI - Downloads"/></a>
27
- <a href="https://github.com/swarmauri/swarmauri-sdk/pkgs/pkgs/swarmauri_middleware_bulkhead">
28
- <img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/swarmauri/swarmauri-sdk/pkgs/pkgs/swarmauri_middleware_bulkhead&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false" alt="GitHub Hits"/></a>
29
- <a href="https://pypi.org/project/swarmauri/swarmauri_middleware_bulkhead">
30
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_bulkhead" alt="PyPI - Python Version"/></a>
31
- <a href="https://pypi.org/project/swarmauri/swarmauri_middleware_bulkhead">
32
- <img src="https://img.shields.io/pypi/l/swarmauri_middleware_bulkhead" alt="PyPI - License"/></a>
33
- <br />
34
- <a href="https://pypi.org/project/swarmauri/swarmauri_middleware_bulkhead">
35
- <img src="https://img.shields.io/pypi/v/swarmauri_middleware_bulkhead?label=swarmauri_middleware_bulkhead&color=green" alt="PyPI - swarmauri_middleware_bulkhead"/></a>
36
- </p>
37
-
38
- ---
39
-
40
- # `swarmauri_middleware_bulkhead`
41
-
42
- ## Overview
43
-
44
- The `swarmauri_middleware_bulkhead` package provides a middleware implementation for controlling concurrency isolation in FastAPI applications. It uses a semaphore-based approach to limit the number of concurrent requests, preventing resource overload and ensuring reliable service operation.
45
-
46
- ## Features
47
-
48
- - **Concurrency Control**: Restricts the maximum number of simultaneous requests
49
- - **Semaphore-based Management**: Efficiently manages request queuing and processing
50
- - **Logging Integration**: Provides detailed logging for request processing and errors
51
- - **Configurable**: Allows customizing the maximum concurrency level
52
- - **Compatibility**: Works seamlessly with FastAPI applications
53
-
54
- ## Requirements
55
-
56
- - Python 3.10+
57
- - FastAPI
58
- - `swarmauri_core` package
59
- - `swarmauri_base` package
60
-
61
- ## Installation
62
-
63
- To install the package, use Poetry or pip:
@@ -1,42 +0,0 @@
1
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
2
-
3
- <p align="center">
4
- <a href="https://pypi.org/project/swarmauri_middleware_bulkhead/">
5
- <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_bulkhead" alt="PyPI - Downloads"/></a>
6
- <a href="https://github.com/swarmauri/swarmauri-sdk/pkgs/pkgs/swarmauri_middleware_bulkhead">
7
- <img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/swarmauri/swarmauri-sdk/pkgs/pkgs/swarmauri_middleware_bulkhead&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false" alt="GitHub Hits"/></a>
8
- <a href="https://pypi.org/project/swarmauri/swarmauri_middleware_bulkhead">
9
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_bulkhead" alt="PyPI - Python Version"/></a>
10
- <a href="https://pypi.org/project/swarmauri/swarmauri_middleware_bulkhead">
11
- <img src="https://img.shields.io/pypi/l/swarmauri_middleware_bulkhead" alt="PyPI - License"/></a>
12
- <br />
13
- <a href="https://pypi.org/project/swarmauri/swarmauri_middleware_bulkhead">
14
- <img src="https://img.shields.io/pypi/v/swarmauri_middleware_bulkhead?label=swarmauri_middleware_bulkhead&color=green" alt="PyPI - swarmauri_middleware_bulkhead"/></a>
15
- </p>
16
-
17
- ---
18
-
19
- # `swarmauri_middleware_bulkhead`
20
-
21
- ## Overview
22
-
23
- The `swarmauri_middleware_bulkhead` package provides a middleware implementation for controlling concurrency isolation in FastAPI applications. It uses a semaphore-based approach to limit the number of concurrent requests, preventing resource overload and ensuring reliable service operation.
24
-
25
- ## Features
26
-
27
- - **Concurrency Control**: Restricts the maximum number of simultaneous requests
28
- - **Semaphore-based Management**: Efficiently manages request queuing and processing
29
- - **Logging Integration**: Provides detailed logging for request processing and errors
30
- - **Configurable**: Allows customizing the maximum concurrency level
31
- - **Compatibility**: Works seamlessly with FastAPI applications
32
-
33
- ## Requirements
34
-
35
- - Python 3.10+
36
- - FastAPI
37
- - `swarmauri_core` package
38
- - `swarmauri_base` package
39
-
40
- ## Installation
41
-
42
- To install the package, use Poetry or pip: