-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat; init * Feat: add redis response and fix nats, redis response * Fix: unificate code * Fix: remove some args * Fix: rewrite init method, override as_publish_kwargs * chore: add DeprecationWarning for ReplyConfig * tests: check RMQ DeprecationWarning * lint: fix mypy * Feat: stage 1 add response to all brokers, need specify to "Broker"Response class * fix: correct Response subclass usage * docs: generate API * fix: wait for connect in Redis ping * docs: generate API * tests: confluent big timeout * fix: confluent test_response --------- Co-authored-by: Daniil Dumchenko <[email protected]> Co-authored-by: Nikita Pastukhov <[email protected]>
- Loading branch information
1 parent
2dc9f45
commit 36e5a17
Showing
22 changed files
with
464 additions
and
41 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
11 changes: 11 additions & 0 deletions
11
docs/docs/en/api/faststream/broker/response/ensure_response.md
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# 0.5 - API | ||
# 2 - Release | ||
# 3 - Contributing | ||
# 5 - Template Page | ||
# 10 - Default | ||
search: | ||
boost: 0.5 | ||
--- | ||
|
||
::: faststream.broker.response.ensure_response |
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,5 +1,37 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from typing_extensions import override | ||
|
||
from faststream.broker.response import Response | ||
|
||
if TYPE_CHECKING: | ||
from faststream.types import AnyDict, SendableMessage | ||
|
||
|
||
class KafkaResponse(Response): | ||
pass | ||
def __init__( | ||
self, | ||
body: "SendableMessage", | ||
*, | ||
headers: Optional["AnyDict"] = None, | ||
correlation_id: Optional[str] = None, | ||
timestamp_ms: Optional[int] = None, | ||
key: Optional[bytes] = None, | ||
) -> None: | ||
super().__init__( | ||
body=body, | ||
headers=headers, | ||
correlation_id=correlation_id, | ||
) | ||
|
||
self.timestamp_ms = timestamp_ms | ||
self.key = key | ||
|
||
@override | ||
def as_publish_kwargs(self) -> "AnyDict": | ||
publish_options = { | ||
**super().as_publish_kwargs(), | ||
"timestamp_ms": self.timestamp_ms, | ||
"key": self.key, | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,37 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from typing_extensions import override | ||
|
||
from faststream.broker.response import Response | ||
|
||
if TYPE_CHECKING: | ||
from faststream.types import AnyDict, SendableMessage | ||
|
||
|
||
class KafkaResponse(Response): | ||
pass | ||
def __init__( | ||
self, | ||
body: "SendableMessage", | ||
*, | ||
headers: Optional["AnyDict"] = None, | ||
correlation_id: Optional[str] = None, | ||
timestamp_ms: Optional[int] = None, | ||
key: Optional[bytes] = None, | ||
) -> None: | ||
super().__init__( | ||
body=body, | ||
headers=headers, | ||
correlation_id=correlation_id, | ||
) | ||
|
||
self.timestamp_ms = timestamp_ms | ||
self.key = key | ||
|
||
@override | ||
def as_publish_kwargs(self) -> "AnyDict": | ||
publish_options = { | ||
**super().as_publish_kwargs(), | ||
"timestamp_ms": self.timestamp_ms, | ||
"key": self.key, | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,33 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from typing_extensions import override | ||
|
||
from faststream.broker.response import Response | ||
|
||
if TYPE_CHECKING: | ||
from faststream.types import AnyDict, SendableMessage | ||
|
||
|
||
class NatsResponse(Response): | ||
pass | ||
def __init__( | ||
self, | ||
body: "SendableMessage", | ||
*, | ||
headers: Optional["AnyDict"] = None, | ||
correlation_id: Optional[str] = None, | ||
stream: Optional[str] = None, | ||
) -> None: | ||
super().__init__( | ||
body=body, | ||
headers=headers, | ||
correlation_id=correlation_id, | ||
) | ||
self.stream = stream | ||
|
||
@override | ||
def as_publish_kwargs(self) -> "AnyDict": | ||
publish_options = { | ||
**super().as_publish_kwargs(), | ||
"stream": self.stream, | ||
} | ||
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
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,5 +1,64 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from typing_extensions import override | ||
|
||
from faststream.broker.response import Response | ||
|
||
if TYPE_CHECKING: | ||
from aio_pika.abc import DateType, TimeoutType | ||
|
||
from faststream.rabbit.types import AioPikaSendableMessage | ||
from faststream.types import AnyDict | ||
|
||
|
||
class RabbitResponse(Response): | ||
pass | ||
def __init__( | ||
self, | ||
body: "AioPikaSendableMessage", | ||
*, | ||
headers: Optional["AnyDict"] = None, | ||
correlation_id: Optional[str] = None, | ||
message_id: Optional[str] = None, | ||
mandatory: bool = True, | ||
immediate: bool = False, | ||
timeout: "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 = { | ||
**super().as_publish_kwargs(), | ||
"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
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
Oops, something went wrong.