-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: rewrite init method, override as_publish_kwargs
- Loading branch information
Daniil Dumchenko
committed
Jul 22, 2024
1 parent
7138709
commit 17d31b8
Showing
5 changed files
with
125 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,65 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from typing_extensions import override | ||
|
||
from faststream.broker.response import Response | ||
|
||
if TYPE_CHECKING: | ||
from faststream.rabbit import RabbitQueue | ||
from aio_pika.abc import DateType, TimeoutType | ||
|
||
from faststream.rabbit.types import AioPikaSendableMessage | ||
from faststream.types import AnyDict | ||
|
||
|
||
class RabbitResponse(Response): | ||
def __init__( | ||
self, | ||
body: "AioPikaSendableMessage", | ||
*, | ||
headers: Optional["AnyDict"] = None, | ||
correlation_id: Optional[str] = None, | ||
queue: Optional["RabbitQueue"] = None, | ||
routing_key: str = "", | ||
message_id: Optional[str] = None, | ||
rpc: bool = False, | ||
rpc_timeout: Optional[float] = 30.0, | ||
raise_timeout: bool = False, | ||
) -> None: ... | ||
mandatory: Optional[bool] = None, | ||
immediate: Optional[bool] = None, | ||
timeout: Optional["TimeoutType"] = None, | ||
persist: Optional[bool] = None, | ||
priority: Optional[int] = None, | ||
message_type: Optional[str] = None, | ||
content_type: Optional[str] = None, | ||
expiration: Optional["DateType"] = None, | ||
content_encoding: Optional[str] = None | ||
) -> None: | ||
super().__init__( | ||
body=body, | ||
headers=headers, | ||
correlation_id=correlation_id, | ||
) | ||
|
||
self.message_id = message_id | ||
self.mandatory = mandatory | ||
self.immediate = immediate | ||
self.timeout = timeout | ||
self.persist = persist | ||
self.priority = priority | ||
self.message_type = message_type | ||
self.content_type = content_type | ||
self.expiration = expiration | ||
self.content_encoding = content_encoding | ||
|
||
@override | ||
def as_publish_kwargs(self) -> "AnyDict": | ||
publish_options = { | ||
"headers": self.headers, | ||
"correlation_id": self.correlation_id, | ||
"message_id": self.message_id, | ||
"mandatory": self.mandatory, | ||
"immediate": self.immediate, | ||
"timeout": self.timeout, | ||
"persist": self.persist, | ||
"priority": self.priority, | ||
"message_type": self.message_type, | ||
"content_type": self.content_type, | ||
"expiration": self.expiration, | ||
"content_encoding": self.content_encoding | ||
} | ||
return publish_options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters