10000 feat: type client args by pepellsd · Pull Request #2165 · ag2ai/faststream · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: type client args #2165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
],
Expand All @@ -185,5 +185,5 @@
}
]
},
"generated_at": "2025-03-21T16:04:45Z"
"generated_at": "2025-04-06T21:08:57Z"
}
1 change: 1 addition & 0 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/rabbit/utils/RabbitClientProperties.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.rabbit.utils.RabbitClientProperties
17 changes: 17 additions & 0 deletions docs/docs/en/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions faststream/rabbit/broker/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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[
Expand Down Expand Up @@ -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[
Expand Down
13 changes: 9 additions & 4 deletions faststream/rabbit/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import TYPE_CHECKING, Any, Optional, Union
from typing import TYPE_CHECKING, Any, Optional, TypedDict, Union

from aio_pika.connection import make_url

from faststream.rabbit.schemas.constants import ExchangeType

if TYPE_CHECKING:
from aio_pika.abc import SSLOptions
from pamqp.common import FieldTable
from yarl import URL

from faststream.rabbit.schemas import RabbitExchange
Expand All @@ -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."""
Expand All @@ -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),
Expand All @@ -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
Loading
0