Bases: FakePublisher
Publisher Interface implementation to use as RPC or REPLY TO answer publisher.
Source code in faststream/redis/publisher/fake.py
| def __init__(
self,
producer: "ProducerProto[RedisPublishCommand]",
channel: str,
message_format: type["MessageFormat"],
) -> None:
super().__init__(producer=producer)
self.channel = channel
self.message_format = message_format
|
channel
instance-attribute
message_format = message_format
patch_command
Source code in faststream/redis/publisher/fake.py
| def patch_command(
self,
cmd: Union["PublishCommand", "RedisPublishCommand"],
) -> "RedisPublishCommand":
cmd = super().patch_command(cmd)
real_cmd = RedisPublishCommand.from_cmd(cmd, message_format=self.message_format)
real_cmd.destination = self.channel
return real_cmd
|
publish
async
publish(message, /, *, correlation_id=None)
Source code in faststream/_internal/endpoint/publisher/fake.py
| async def publish(
self,
message: SendableMessage,
/,
*,
correlation_id: str | None = None,
) -> Any | None:
msg = (
f"`{self.__class__.__name__}` can be used only to publish "
"a response for `reply-to` or `RPC` messages."
)
raise NotImplementedError(msg)
|
request
async
request(message, /, *, correlation_id=None)
Source code in faststream/_internal/endpoint/publisher/fake.py
| async def request(
self,
message: "SendableMessage",
/,
*,
correlation_id: str | None = None,
) -> Any:
msg = (
f"`{self.__class__.__name__}` can be used only to publish "
"a response for `reply-to` or `RPC` messages."
)
raise NotImplementedError(msg)
|