Skip to content

RedisRoute

faststream.redis.broker.RedisRoute #

RedisRoute(
    call: Callable[..., SendableMessage]
    | Callable[..., Awaitable[SendableMessage]],
    channel: Union[str, PubSub] | None = None,
    *,
    publishers: Iterable[RedisPublisher] = (),
    list: Union[str, ListSub] | None = None,
    stream: Union[str, StreamSub] | None = None,
    dependencies: Sequence[Dependant] = (),
    parser: Optional[CustomCallable] = None,
    decoder: Optional[CustomCallable] = None,
    ack_policy: AckPolicy = EMPTY,
    no_reply: bool = False,
    title: str | None = None,
    description: str | None = None,
    include_in_schema: bool = True,
    max_workers: int | None = None,
)

Bases: SubscriberRoute

Class to store delayed RedisBroker subscriber registration.

Initialize the RedisRoute.

PARAMETER DESCRIPTION
call

Message handler function to wrap the same with @broker.subscriber(...) way.

TYPE: Callable[..., SendableMessage] | Callable[..., Awaitable[SendableMessage]]

channel

Redis PubSub object name to send message.

TYPE: Union[str, PubSub] | None DEFAULT: None

publishers

Redis publishers to broadcast the handler result.

TYPE: Iterable[RedisPublisher] DEFAULT: ()

list

Redis List object name to send message.

TYPE: Union[str, ListSub] | None DEFAULT: None

stream

Redis Stream object name to send message.

TYPE: Union[str, StreamSub] | None DEFAULT: None

dependencies

Dependencies list ([Dependant(),]) to apply to the subscriber.

TYPE: Sequence[Dependant] DEFAULT: ()

parser

Parser to map original aio_pika.IncomingMessage Msg to FastStream one.

TYPE: Optional[CustomCallable] DEFAULT: None

decoder

Function to decode FastStream msg bytes body to python objects.

TYPE: Optional[CustomCallable] DEFAULT: None

ack_policy

Acknowledgement policy of the handler.

TYPE: AckPolicy DEFAULT: EMPTY

no_reply

Whether to disable FastStream RPC and Reply To auto responses or not.

TYPE: bool DEFAULT: False

title

AsyncAPI subscriber object title.

TYPE: str | None DEFAULT: None

description

AsyncAPI subscriber object description. Uses decorated docstring as default.

TYPE: str | None DEFAULT: None

include_in_schema

Whetever to include operation in AsyncAPI schema or not.

TYPE: bool DEFAULT: True

max_workers

Number of workers to process messages concurrently.

TYPE: int | None DEFAULT: None

Source code in faststream/redis/broker/router.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
def __init__(
    self,
    call: Callable[..., "SendableMessage"]
    | Callable[..., Awaitable["SendableMessage"]],
    channel: Union[str, "PubSub"] | None = None,
    *,
    publishers: Iterable["RedisPublisher"] = (),
    list: Union[str, "ListSub"] | None = None,
    stream: Union[str, "StreamSub"] | None = None,
    dependencies: Sequence["Dependant"] = (),
    parser: Optional["CustomCallable"] = None,
    decoder: Optional["CustomCallable"] = None,
    ack_policy: AckPolicy = EMPTY,
    no_reply: bool = False,
    title: str | None = None,
    description: str | None = None,
    include_in_schema: bool = True,
    max_workers: int | None = None,
) -> None:
    """Initialize the RedisRoute.

    Args:
        call:
            Message handler function to wrap the same with `@broker.subscriber(...)` way.
        channel:
            Redis PubSub object name to send message.
        publishers:
            Redis publishers to broadcast the handler result.
        list:
            Redis List object name to send message.
        stream:
            Redis Stream object name to send message.
        dependencies:
            Dependencies list (`[Dependant(),]`) to apply to the subscriber.
        parser:
            Parser to map original **aio_pika.IncomingMessage** Msg to FastStream one.
        decoder:
            Function to decode FastStream msg bytes body to python objects.
        ack_policy:
            Acknowledgement policy of the handler.
        no_reply:
            Whether to disable **FastStream** RPC and Reply To auto responses or not.
        title:
            AsyncAPI subscriber object title.
        description:
            AsyncAPI subscriber object description. Uses decorated docstring as default.
        include_in_schema:
            Whetever to include operation in AsyncAPI schema or not.
        max_workers:
            Number of workers to process messages concurrently.
    """
    super().__init__(
        call,
        channel=channel,
        publishers=publishers,
        list=list,
        stream=stream,
        dependencies=dependencies,
        max_workers=max_workers,
        parser=parser,
        decoder=decoder,
        ack_policy=ack_policy,
        no_reply=no_reply,
        title=title,
        description=description,
        include_in_schema=include_in_schema,
    )

args instance-attribute #

args: Iterable[Any] = args

kwargs instance-attribute #

kwargs: dict[str, Any] = kwargs

call instance-attribute #

call: Callable[..., Any] = call

publishers instance-attribute #

publishers: Iterable[Any] = publishers