Skip to content

Commit

Permalink
refactor: add type annotations for RabbitQueue and enum for queue type (
Browse files Browse the repository at this point in the history
#2002)

* add type annotations for RabbitQueue and enum for queue type

* add default for queue type

* minor fixes and docs

* chore: polish types

* feat: add SetupError in incorrect RabbitQueue params case

* fix: correct not-empty durable processing

---------

Co-authored-by: Pastukhov Nikita <[email protected]>
Co-authored-by: Nikita Pastukhov <[email protected]>
  • Loading branch information
3 people authored Dec 23, 2024
1 parent 958fdd2 commit 82f5afa
Show file tree
Hide file tree
Showing 16 changed files with 313 additions and 54 deletions.
12 changes: 12 additions & 0 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ search:
- [TelemetrySettingsProvider](public_api/faststream/opentelemetry/TelemetrySettingsProvider.md)
- rabbit
- [ExchangeType](public_api/faststream/rabbit/ExchangeType.md)
- [QueueType](public_api/faststream/rabbit/QueueType.md)
- [RabbitBroker](public_api/faststream/rabbit/RabbitBroker.md)
- [RabbitExchange](public_api/faststream/rabbit/RabbitExchange.md)
- [RabbitPublisher](public_api/faststream/rabbit/RabbitPublisher.md)
Expand Down Expand Up @@ -872,6 +873,7 @@ search:
- [PublishingStatus](api/faststream/prometheus/types/PublishingStatus.md)
- rabbit
- [ExchangeType](api/faststream/rabbit/ExchangeType.md)
- [QueueType](api/faststream/rabbit/QueueType.md)
- [RabbitBroker](api/faststream/rabbit/RabbitBroker.md)
- [RabbitExchange](api/faststream/rabbit/RabbitExchange.md)
- [RabbitPublisher](api/faststream/rabbit/RabbitPublisher.md)
Expand Down Expand Up @@ -932,6 +934,7 @@ search:
- schemas
- [BaseRMQInformation](api/faststream/rabbit/schemas/BaseRMQInformation.md)
- [ExchangeType](api/faststream/rabbit/schemas/ExchangeType.md)
- [QueueType](api/faststream/rabbit/schemas/QueueType.md)
- [RabbitExchange](api/faststream/rabbit/schemas/RabbitExchange.md)
- [RabbitQueue](api/faststream/rabbit/schemas/RabbitQueue.md)
- [ReplyConfig](api/faststream/rabbit/schemas/ReplyConfig.md)
Expand All @@ -942,7 +945,16 @@ search:
- proto
- [BaseRMQInformation](api/faststream/rabbit/schemas/proto/BaseRMQInformation.md)
- queue
- [ClassicQueueArgs](api/faststream/rabbit/schemas/queue/ClassicQueueArgs.md)
- [CommonQueueArgs](api/faststream/rabbit/schemas/queue/CommonQueueArgs.md)
- [QueueClassicTypeSpecificArgs](api/faststream/rabbit/schemas/queue/QueueClassicTypeSpecificArgs.md)
- [QueueQuorumTypeSpecificArgs](api/faststream/rabbit/schemas/queue/QueueQuorumTypeSpecificArgs.md)
- [QueueStreamTypeSpecificArgs](api/faststream/rabbit/schemas/queue/QueueStreamTypeSpecificArgs.md)
- [QueueType](api/faststream/rabbit/schemas/queue/QueueType.md)
- [QuorumQueueArgs](api/faststream/rabbit/schemas/queue/QuorumQueueArgs.md)
- [RabbitQueue](api/faststream/rabbit/schemas/queue/RabbitQueue.md)
- [SharedQueueClassicAndQuorumArgs](api/faststream/rabbit/schemas/queue/SharedQueueClassicAndQuorumArgs.md)
- [StreamQueueArgs](api/faststream/rabbit/schemas/queue/StreamQueueArgs.md)
- reply
- [ReplyConfig](api/faststream/rabbit/schemas/reply/ReplyConfig.md)
- security
Expand Down
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/rabbit/QueueType.md
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.rabbit.QueueType
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/rabbit/schemas/QueueType.md
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.rabbit.schemas.QueueType
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.rabbit.schemas.queue.ClassicQueueArgs
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.rabbit.schemas.queue.CommonQueueArgs
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.rabbit.schemas.queue.QueueClassicTypeSpecificArgs
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.rabbit.schemas.queue.QueueQuorumTypeSpecificArgs
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.rabbit.schemas.queue.QueueStreamTypeSpecificArgs
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/rabbit/schemas/queue/QueueType.md
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.rabbit.schemas.queue.QueueType
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.rabbit.schemas.queue.QuorumQueueArgs
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.rabbit.schemas.queue.SharedQueueClassicAndQuorumArgs
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.rabbit.schemas.queue.StreamQueueArgs
6 changes: 2 additions & 4 deletions docs/docs_src/rabbit/subscription/stream.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from faststream import FastStream, Logger
from faststream.rabbit import RabbitBroker, RabbitQueue
from faststream.rabbit import RabbitBroker, RabbitQueue, QueueType

broker = RabbitBroker(max_consumers=10)
app = FastStream(broker)

queue = RabbitQueue(
name="test-stream",
durable=True,
arguments={
"x-queue-type": "stream",
},
queue_type=QueueType.STREAM
)


Expand Down
2 changes: 2 additions & 0 deletions faststream/rabbit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from faststream.rabbit.router import RabbitPublisher, RabbitRoute, RabbitRouter
from faststream.rabbit.schemas import (
ExchangeType,
QueueType,
RabbitExchange,
RabbitQueue,
ReplyConfig,
Expand All @@ -13,6 +14,7 @@

__all__ = (
"ExchangeType",
"QueueType",
"RabbitBroker",
"RabbitExchange",
# Annotations
Expand Down
3 changes: 2 additions & 1 deletion faststream/rabbit/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from faststream.rabbit.schemas.constants import ExchangeType
from faststream.rabbit.schemas.exchange import RabbitExchange
from faststream.rabbit.schemas.proto import BaseRMQInformation
from faststream.rabbit.schemas.queue import RabbitQueue
from faststream.rabbit.schemas.queue import QueueType, RabbitQueue
from faststream.rabbit.schemas.reply import ReplyConfig

__all__ = (
"RABBIT_REPLY",
"BaseRMQInformation",
"ExchangeType",
"QueueType",
"RabbitExchange",
"RabbitQueue",
"ReplyConfig",
Expand Down
Loading

0 comments on commit 82f5afa

Please sign in to comment.