asyncapi-python 0.2.4__tar.gz → 0.2.5__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 (40) hide show
  1. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/PKG-INFO +9 -44
  2. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/README.md +8 -43
  3. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/pyproject.toml +6 -5
  4. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/__init__.py +2 -0
  5. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/base_application.py +3 -0
  6. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/endpoint/base.py +2 -0
  7. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/endpoint/receiver.py +2 -0
  8. asyncapi_python-0.2.5/src/asyncapi_python/amqp/params.py +5 -0
  9. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/generators/amqp/templates/__init__.py.j2 +3 -1
  10. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/generators/amqp/templates/application.py.j2 +3 -3
  11. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/LICENSE +0 -0
  12. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/__init__.py +0 -0
  13. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/connection.py +0 -0
  14. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/endpoint/__init__.py +0 -0
  15. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/endpoint/sender.py +0 -0
  16. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/error.py +0 -0
  17. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/operation.py +0 -0
  18. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/amqp/utils.py +0 -0
  19. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/py.typed +0 -0
  20. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python/utils.py +0 -0
  21. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/__init__.py +0 -0
  22. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/__init__.py +0 -0
  23. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/base.py +0 -0
  24. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/bindings/__init__.py +0 -0
  25. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/bindings/amqp.py +0 -0
  26. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/components.py +0 -0
  27. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/document.py +0 -0
  28. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/document_context.py +0 -0
  29. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/ref.py +0 -0
  30. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/document/utils.py +0 -0
  31. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/generators/__init__.py +0 -0
  32. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/generators/amqp/__init__.py +0 -0
  33. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/generators/amqp/generate.py +0 -0
  34. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/generators/amqp/templates/routes.py.j2 +0 -0
  35. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_codegen/py.typed +0 -0
  36. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_pants/__init__.py +0 -0
  37. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_pants/py.typed +0 -0
  38. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_pants/register.py +0 -0
  39. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_pants/rules.py +0 -0
  40. {asyncapi_python-0.2.4 → asyncapi_python-0.2.5}/src/asyncapi_python_pants/targets.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: asyncapi-python
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Easily generate type-safe and async Python applications from AsyncAPI 3 specifications.
5
5
  License: Apache-2.0
6
6
  Author: Yaroslav Petrov
@@ -28,7 +28,7 @@ Description-Content-Type: text/markdown
28
28
  # AsyncAPI Python Code Generator
29
29
  >
30
30
  > [!IMPORTANT]
31
- > Although commits to dev branch might seem infrequent, the project is under active development **as of March 2025**.
31
+ > Although commits to dev branch might seem infrequent, the project is under active development **as of June 2025**.
32
32
  >
33
33
  > We currently produce only those changes that are required to satisfy our personal use cases.
34
34
  >
@@ -103,7 +103,7 @@ asyncapi_python_service(
103
103
  )
104
104
  ```
105
105
 
106
- This will be generating python module named `asyncapi_app` on `codegen-export` and `export` goals.
106
+ This will be generating python module named `asyncapi_app` on `codegen-export`, and `export` goals.
107
107
  This target can later be used as a dependency of `python_sources`.
108
108
 
109
109
  ```python
@@ -127,51 +127,16 @@ Note that this plugin does not do dependency injection, so asyncapi-python must
127
127
  asyncapi-python[amqp]
128
128
  ```
129
129
 
130
- ### Deploying this plugin into pants monorepo
131
-
132
- In order to deploy this plugin into your pants monorepo, create the following structure inside your plugins folder:
133
-
134
- ```bash
135
- pants-plugins/
136
- └── asyncapi_python_plugin
137
- ├── BUILD
138
- ├── __init__.py
139
- ├── register.py
140
- └── requirements.txt
141
- ```
142
-
143
- `requirements.txt` must contain:
144
-
145
- ```text
146
- asyncapi-python
147
- ```
148
-
149
- `register.py` should have:
150
-
151
- ```python
152
- from asyncapi_python_pants.register import *
153
- ```
154
-
155
- `BUILD` must include:
156
-
157
- ```python
158
- python_sources(
159
- dependencies=[":reqs"],
160
- )
161
-
162
- python_requirements(
163
- name="reqs",
164
- )
165
- ```
166
-
167
- `__init__.py` can be empty, but it has to exist.
168
-
169
- Finally, add `pants-plugins` to your `PYTHONPATH`, and add the created folder as a backend package:
130
+ ### Deploying this plugin into your pants monorepo
170
131
 
171
132
  ```toml
172
133
  # pants.toml
134
+ plugins = [
135
+ "asyncapi_python[codegen]==0.2.5", # Plugin version MUST match the version of your python clients
136
+ ...
137
+ ]
173
138
  backend_packages = [
174
- "asyncapi_python_plugin",
139
+ "asyncapi_python_pants",
175
140
  ...
176
141
  ]
177
142
  pythonpath = ["%(buildroot)s/pants-plugins"]
@@ -1,7 +1,7 @@
1
1
  # AsyncAPI Python Code Generator
2
2
  >
3
3
  > [!IMPORTANT]
4
- > Although commits to dev branch might seem infrequent, the project is under active development **as of March 2025**.
4
+ > Although commits to dev branch might seem infrequent, the project is under active development **as of June 2025**.
5
5
  >
6
6
  > We currently produce only those changes that are required to satisfy our personal use cases.
7
7
  >
@@ -76,7 +76,7 @@ asyncapi_python_service(
76
76
  )
77
77
  ```
78
78
 
79
- This will be generating python module named `asyncapi_app` on `codegen-export` and `export` goals.
79
+ This will be generating python module named `asyncapi_app` on `codegen-export`, and `export` goals.
80
80
  This target can later be used as a dependency of `python_sources`.
81
81
 
82
82
  ```python
@@ -100,51 +100,16 @@ Note that this plugin does not do dependency injection, so asyncapi-python must
100
100
  asyncapi-python[amqp]
101
101
  ```
102
102
 
103
- ### Deploying this plugin into pants monorepo
104
-
105
- In order to deploy this plugin into your pants monorepo, create the following structure inside your plugins folder:
106
-
107
- ```bash
108
- pants-plugins/
109
- └── asyncapi_python_plugin
110
- ├── BUILD
111
- ├── __init__.py
112
- ├── register.py
113
- └── requirements.txt
114
- ```
115
-
116
- `requirements.txt` must contain:
117
-
118
- ```text
119
- asyncapi-python
120
- ```
121
-
122
- `register.py` should have:
123
-
124
- ```python
125
- from asyncapi_python_pants.register import *
126
- ```
127
-
128
- `BUILD` must include:
129
-
130
- ```python
131
- python_sources(
132
- dependencies=[":reqs"],
133
- )
134
-
135
- python_requirements(
136
- name="reqs",
137
- )
138
- ```
139
-
140
- `__init__.py` can be empty, but it has to exist.
141
-
142
- Finally, add `pants-plugins` to your `PYTHONPATH`, and add the created folder as a backend package:
103
+ ### Deploying this plugin into your pants monorepo
143
104
 
144
105
  ```toml
145
106
  # pants.toml
107
+ plugins = [
108
+ "asyncapi_python[codegen]==0.2.5", # Plugin version MUST match the version of your python clients
109
+ ...
110
+ ]
146
111
  backend_packages = [
147
- "asyncapi_python_plugin",
112
+ "asyncapi_python_pants",
148
113
  ...
149
114
  ]
150
115
  pythonpath = ["%(buildroot)s/pants-plugins"]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "asyncapi-python"
3
- version = "0.2.4"
3
+ version = "0.2.5"
4
4
  license = "Apache-2.0"
5
5
  description = "Easily generate type-safe and async Python applications from AsyncAPI 3 specifications."
6
6
  authors = ["Yaroslav Petrov <yaroslav.v.petrov@gmail.com>"]
@@ -52,9 +52,10 @@ pex = "*"
52
52
  requires = ["poetry-core"]
53
53
  build-backend = "poetry.core.masonry.api"
54
54
 
55
- [tool.pytest.ini_options]
56
- asyncio_mode = "auto"
57
- asyncio_default_fixture_loop_scope = "function"
58
-
59
55
  [tool.poetry.requires-plugins]
60
56
  poetry-plugin-export = ">=1.8"
57
+
58
+ [tool.pytest.ini_options]
59
+ asyncio_mode = "auto"
60
+ asyncio_default_fixture_loop_scope = "session"
61
+ asyncio_default_test_loop_scope = "session"
@@ -19,9 +19,11 @@ from .endpoint import Receiver, RpcReceiver, Sender, RpcSender, EndpointParams
19
19
  from .operation import Operation
20
20
  from .utils import union_model
21
21
  from .error import Rejection, RejectedError
22
+ from .params import AmqpParams
22
23
 
23
24
  __all__ = [
24
25
  "channel_pool",
26
+ "AmqpParams",
25
27
  "AmqpPool",
26
28
  "BaseApplication",
27
29
  "Router",
@@ -23,6 +23,7 @@ from .error import RejectedError
23
23
  from .endpoint import EndpointParams
24
24
  from .connection import channel_pool
25
25
  from .utils import encode_message, decode_message
26
+ from .params import AmqpParams
26
27
  from typing import Generic, Optional, TypeVar
27
28
 
28
29
 
@@ -61,6 +62,7 @@ class BaseApplication(Generic[P, C]):
61
62
  amqp_uri: str,
62
63
  producer_factory: type[P],
63
64
  consumer_factory: type[C],
65
+ amqp_params: AmqpParams,
64
66
  ):
65
67
  self.__params = EndpointParams(
66
68
  pool=channel_pool(amqp_uri),
@@ -69,6 +71,7 @@ class BaseApplication(Generic[P, C]):
69
71
  register_correlation_id=self.__register_correlation_id,
70
72
  stop_application=self.stop,
71
73
  app_id=str(uuid4()),
74
+ amqp_params=amqp_params,
72
75
  )
73
76
  self.__reply_futures: dict[
74
77
  str,
@@ -31,6 +31,7 @@ from pydantic import BaseModel
31
31
  from ..error import Rejection, RejectedError
32
32
  from ..connection import AmqpPool
33
33
  from ..operation import Operation
34
+ from ..params import AmqpParams
34
35
  from aio_pika.abc import (
35
36
  AbstractRobustChannel,
36
37
  AbstractRobustQueue,
@@ -64,6 +65,7 @@ class EndpointParams:
64
65
  ]
65
66
  app_id: str
66
67
  stop_application: Callable[[], Awaitable[None]]
68
+ amqp_params: AmqpParams
67
69
 
68
70
  @property
69
71
  def reply_queue_name(self) -> str:
@@ -45,6 +45,8 @@ class AbstractReceiver(AbstractEndpoint[I, O]):
45
45
  print("start", self._op)
46
46
  if self._fn:
47
47
  async with self._params.pool.acquire() as ch:
48
+ if prefetch_count := self._params.amqp_params.get("prefetch_count"):
49
+ await ch.set_qos(prefetch_count=prefetch_count)
48
50
  q = self._queue = await self._declare(ch)
49
51
  self._consumer_tag = await q.consume(self._consumer)
50
52
  return
@@ -0,0 +1,5 @@
1
+ from typing import TypedDict
2
+
3
+
4
+ class AmqpParams(TypedDict, total=False):
5
+ prefetch_count: int
@@ -11,4 +11,6 @@
11
11
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  See the License for the specific language governing permissions and
13
13
  limitations under the License. #}
14
- from .application import Application
14
+ from .application import Application
15
+
16
+ __all__ = ["Application"]
@@ -13,9 +13,9 @@
13
13
  limitations under the License. #}
14
14
  from .consumer import _Router_0 as Consumer
15
15
  from .producer import _Router_0 as Producer
16
- from asyncapi_python.amqp.base_application import BaseApplication
16
+ from asyncapi_python.amqp import BaseApplication, AmqpParams
17
17
 
18
18
 
19
19
  class Application(BaseApplication[Producer, Consumer]):
20
- def __init__(self, amqp_uri: str):
21
- super().__init__(amqp_uri, Producer, Consumer)
20
+ def __init__(self, amqp_uri: str, amqp_params: AmqpParams = {}):
21
+ super().__init__(amqp_uri, Producer, Consumer, amqp_params)
File without changes