From 5937eadab83156c288bf743c8b98de3cdf856181 Mon Sep 17 00:00:00 2001 From: pepellsd Date: Mon, 7 Apr 2025 00:16:56 +0300 Subject: [PATCH] feat: type client args --- .secrets.baseline | 4 ++-- docs/docs/SUMMARY.md | 1 + .../rabbit/utils/RabbitClientProperties.md | 11 +++++++++++ docs/docs/en/release.md | 17 +++++++++++++++++ faststream/rabbit/broker/broker.py | 6 +++--- faststream/rabbit/utils.py | 13 +++++++++---- 6 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 docs/docs/en/api/faststream/rabbit/utils/RabbitClientProperties.md diff --git a/.secrets.baseline b/.secrets.baseline index 6bebf7e9df..a907513aaf 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -160,7 +160,7 @@ "filename": "docs/docs/en/release.md", "hashed_secret": "35675e68f4b5af7b995d9205ad0fc43842f16450", "is_verified": false, - "line_number": 2035, + "line_number": 2052, "is_secret": false } ], @@ -185,5 +185,5 @@ } ] }, - "generated_at": "2025-03-21T16:04:45Z" + "generated_at": "2025-04-06T21:08:57Z" } diff --git a/docs/docs/SUMMARY.md b/docs/docs/SUMMARY.md index 3fc83a5f91..45c5c81908 100644 --- a/docs/docs/SUMMARY.md +++ b/docs/docs/SUMMARY.md @@ -983,6 +983,7 @@ search: - [apply_pattern](api/faststream/rabbit/testing/apply_pattern.md) - [build_message](api/faststream/rabbit/testing/build_message.md) - utils + - [RabbitClientProperties](api/faststream/rabbit/utils/RabbitClientProperties.md) - [build_url](api/faststream/rabbit/utils/build_url.md) - [build_virtual_host](api/faststream/rabbit/utils/build_virtual_host.md) - [is_routing_exchange](api/faststream/rabbit/utils/is_routing_exchange.md) diff --git a/docs/docs/en/api/faststream/rabbit/utils/RabbitClientProperties.md b/docs/docs/en/api/faststream/rabbit/utils/RabbitClientProperties.md new file mode 100644 index 0000000000..c7b054d94b --- /dev/null +++ b/docs/docs/en/api/faststream/rabbit/utils/RabbitClientProperties.md @@ -0,0 +1,11 @@ +--- +# 0.5 - API +# 2 - Release +# 3 - Contributing +# 5 - Template Page +# 10 - Default +search: + boost: 0.5 +--- + +::: faststream.rabbit.utils.RabbitClientProperties diff --git a/docs/docs/en/release.md b/docs/docs/en/release.md index 80578a97d2..c7b6580e7b 100644 --- a/docs/docs/en/release.md +++ b/docs/docs/en/release.md @@ -12,6 +12,23 @@ hide: --- # Release Notes +## 0.5.38 + +### What's Changed + +* Update Release Notes for 0.5.37 by @airt-release-notes-updater in [#2140](https://github.com/ag2ai/faststream/pull/2140){.external-link target="_blank"} +* chore(deps): bump the pip group with 6 updates by [@dependabot](https://github.com/dependabot){.external-link target="_blank"} in [#2144](https://github.com/ag2ai/faststream/pull/2144){.external-link target="_blank"} +* fix: pydantic211 compat by [@Lancetnik](https://github.com/Lancetnik){.external-link target="_blank"} in [#2150](https://github.com/ag2ai/faststream/pull/2150){.external-link target="_blank"} +* Tweak RabbitMQ queue argument lists by @Arseniy-Popov in [#2148](https://github.com/ag2ai/faststream/pull/2148){.external-link target="_blank"} +* fix: prevent duplicate logging handler registration when calling broker.start() by [@banksemi](https://github.com/banksemi){.external-link target="_blank"} in [#2153](https://github.com/ag2ai/faststream/pull/2153){.external-link target="_blank"} +* chore(deps): bump the pip group with 5 updates by [@dependabot](https://github.com/dependabot){.external-link target="_blank"} in [#2154](https://github.com/ag2ai/faststream/pull/2154){.external-link target="_blank"} +* Move to ag2ai organization by [@davorrunje](https://github.com/davorrunje){.external-link target="_blank"} in [#2156](https://github.com/ag2ai/faststream/pull/2156){.external-link target="_blank"} + +### New Contributors +* [@banksemi](https://github.com/banksemi){.external-link target="_blank"} made their first contribution in [#2153](https://github.com/ag2ai/faststream/pull/2153){.external-link target="_blank"} + +**Full Changelog**: [#0.5.37...0.5.38](https://github.com/ag2ai/faststream/compare/0.5.37...0.5.38){.external-link target="_blank"} + ## 0.5.37 ### What's Changed diff --git a/faststream/rabbit/broker/broker.py b/faststream/rabbit/broker/broker.py index 2e650372d2..2c80d1d206 100644 --- a/faststream/rabbit/broker/broker.py +++ b/faststream/rabbit/broker/broker.py @@ -46,7 +46,6 @@ ) from aio_pika.abc import DateType, HeadersType, SSLOptions, TimeoutType from fast_depends.dependencies import Depends - from pamqp.common import FieldTable from yarl import URL from faststream.asyncapi import schema as asyncapi @@ -56,6 +55,7 @@ ) from faststream.rabbit.message import RabbitMessage from faststream.rabbit.types import AioPikaSendableMessage + from faststream.rabbit.utils import RabbitClientProperties from faststream.security import BaseSecurity from faststream.types import AnyDict, Decorator, LoggerProto @@ -97,7 +97,7 @@ def __init__( Doc("Extra ssl options to establish connection."), ] = None, client_properties: Annotated[ - Optional["FieldTable"], + Optional["RabbitClientProperties"], Doc("Add custom client capability."), ] = None, timeout: Annotated[ @@ -333,7 +333,7 @@ async def connect( # type: ignore[override] Doc("Extra ssl options to establish connection."), ] = None, client_properties: Annotated[ - Optional["FieldTable"], + Optional["RabbitClientProperties"], Doc("Add custom client capability."), ] = None, security: Annotated[ diff --git a/faststream/rabbit/utils.py b/faststream/rabbit/utils.py index a5d48a0580..131d0c9e84 100644 --- a/faststream/rabbit/utils.py +++ b/faststream/rabbit/utils.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional, TypedDict, Union from aio_pika.connection import make_url @@ -6,7 +6,6 @@ if TYPE_CHECKING: from aio_pika.abc import SSLOptions - from pamqp.common import FieldTable from yarl import URL from faststream.rabbit.schemas import RabbitExchange @@ -33,7 +32,7 @@ def build_url( virtualhost: Optional[str] = None, ssl: Optional[bool] = None, ssl_options: Optional["SSLOptions"] = None, - client_properties: Optional["FieldTable"] = None, + client_properties: Optional["RabbitClientProperties"] = None, **kwargs: Any, ) -> "URL": """Construct URL object from attributes.""" @@ -50,7 +49,7 @@ def build_url( virtualhost=build_virtual_host(url, virtualhost, original_url.path), ssl=use_ssl, ssl_options=ssl_options, - client_properties=client_properties, + client_properties=client_properties, # type: ignore[arg-type] **{ **kwargs, **dict(original_url.query), @@ -64,3 +63,9 @@ def is_routing_exchange(exchange: Optional["RabbitExchange"]) -> bool: ExchangeType.DIRECT.value, ExchangeType.TOPIC.value, ) + + +class RabbitClientProperties(TypedDict, total=False): + heartbeat: int + connection_timeout: int + channel_max: int