Skip to content

RedisResponse

faststream.redis.response.RedisResponse #

RedisResponse(
    body: Optional[SendableMessage] = None,
    *,
    headers: dict[str, Any] | None = None,
    correlation_id: str | None = None,
    maxlen: int | None = None,
    message_format: type[
        MessageFormat
    ] = BinaryMessageFormatV1,
)

Bases: Response

Source code in faststream/redis/response.py
def __init__(
    self,
    body: Optional["SendableMessage"] = None,
    *,
    headers: dict[str, Any] | None = None,
    correlation_id: str | None = None,
    maxlen: int | None = None,
    message_format: type["MessageFormat"] = BinaryMessageFormatV1,
) -> None:
    super().__init__(
        body=body,
        headers=headers,
        correlation_id=correlation_id,
    )
    self.maxlen = maxlen
    self.message_format = message_format

maxlen instance-attribute #

maxlen = maxlen

message_format instance-attribute #

message_format = message_format

body instance-attribute #

body = body

headers instance-attribute #

headers = headers or {}

correlation_id instance-attribute #

correlation_id = correlation_id

as_publish_command #

as_publish_command() -> RedisPublishCommand
Source code in faststream/redis/response.py
@override
def as_publish_command(self) -> "RedisPublishCommand":
    return RedisPublishCommand(
        self.body,
        headers=self.headers,
        correlation_id=self.correlation_id,
        _publish_type=PublishType.PUBLISH,
        maxlen=self.maxlen,
        message_format=self.message_format,
        channel="fake-channel",  # it will be replaced by reply-sender
    )

get_publish_key #

get_publish_key() -> Any | None

Get the key for publishing this message.

Override this method in subclasses to provide broker-specific keys. Default implementation returns None (no key).

RETURNS DESCRIPTION
Any | None

The key for publishing, or None if this Response type doesn't use keys.

Source code in faststream/response/response.py
def get_publish_key(self) -> Any | None:
    """Get the key for publishing this message.

    Override this method in subclasses to provide broker-specific keys.
    Default implementation returns None (no key).

    Returns:
        The key for publishing, or None if this Response type doesn't use keys.
    """
    return None