Skip to content

Commit

Permalink
docs: update filters example (#1516)
Browse files Browse the repository at this point in the history
* docs: update filters examples

* chore: update dependencies
  • Loading branch information
Lancetnik committed Jun 10, 2024
1 parent 4405abe commit c20629c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- run: pip install smokeshow

- uses: dawidd6/action-download-artifact@v3.1.4 # nosemgrep
- uses: dawidd6/action-download-artifact@v5 # nosemgrep
with:
workflow: pr_tests.yaml
workflow_conclusion: success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
broker = KafkaBroker("localhost:9092")
app = FastStream(broker)

subscriber = broker.subscriber("test-topic")

@broker.subscriber(
"test-topic",
@subscriber(
filter=lambda msg: msg.content_type == "application/json",
)
async def handle(name: str, user_id: int):
assert name == "John"
assert user_id == 1


@broker.subscriber("test-topic")
@subscriber
async def default_handler(msg: str):
assert msg == "Hello, FastStream!"



@app.after_startup
async def test():
await broker.publish(
Expand Down
8 changes: 4 additions & 4 deletions docs/docs_src/getting_started/subscription/kafka/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
broker = KafkaBroker("localhost:9092")
app = FastStream(broker)

subscriber = broker.subscriber("test-topic")

@broker.subscriber(
"test-topic",
@subscriber(
filter=lambda msg: msg.content_type == "application/json",
)
async def handle(name: str, user_id: int):
assert name == "John"
assert user_id == 1


@broker.subscriber("test-topic")
@subscriber
async def default_handler(msg: str):
assert msg == "Hello, FastStream!"



@app.after_startup
async def test():
await broker.publish(
Expand Down
8 changes: 4 additions & 4 deletions docs/docs_src/getting_started/subscription/nats/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
broker = NatsBroker("nats://localhost:4222")
app = FastStream(broker)

subscriber = broker.subscriber("test-subject")

@broker.subscriber(
"test-subject",
@subscriber(
filter=lambda msg: msg.content_type == "application/json",
)
async def handle(name: str, user_id: int):
assert name == "John"
assert user_id == 1


@broker.subscriber("test-subject")
@subscriber
async def default_handler(msg: str):
assert msg == "Hello, FastStream!"



@app.after_startup
async def test():
await broker.publish(
Expand Down
8 changes: 4 additions & 4 deletions docs/docs_src/getting_started/subscription/rabbit/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
broker = RabbitBroker("amqp://guest:guest@localhost:5672/")
app = FastStream(broker)

subscriber = broker.subscriber("test-queue")

@broker.subscriber(
"test-queue",
@subscriber(
filter=lambda msg: msg.content_type == "application/json",
)
async def handle(name: str, user_id: int):
assert name == "John"
assert user_id == 1


@broker.subscriber("test-queue")
@subscriber
async def default_handler(msg: str):
assert msg == "Hello, FastStream!"



@app.after_startup
async def test():
await broker.publish(
Expand Down
8 changes: 4 additions & 4 deletions docs/docs_src/getting_started/subscription/redis/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
broker = RedisBroker("redis://localhost:6379")
app = FastStream(broker)

subscriber = broker.subscriber("test-channel")

@broker.subscriber(
"test-channel",
@subscriber(
filter=lambda msg: msg.content_type == "application/json",
)
async def handle(name: str, user_id: int):
assert name == "John"
assert user_id == 1


@broker.subscriber("test-channel")
@subscriber
async def default_handler(msg: str):
assert msg == "Hello, FastStream!"



@app.after_startup
async def test():
await broker.publish(
Expand Down
20 changes: 10 additions & 10 deletions docs/includes/getting_started/subscription/filtering/1.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
=== "AIOKafka"
```python linenums="1" hl_lines="10 17"
{!> docs_src/getting_started/subscription/kafka/filter.py [ln:1-19] !}
```python linenums="1" hl_lines="7 9-11 16"
{!> docs_src/getting_started/subscription/kafka/filter.py [ln:1-18] !}
```

=== "Confluent"
```python linenums="1" hl_lines="10 17"
{!> docs_src/getting_started/subscription/confluent/filter.py [ln:1-19] !}
```python linenums="1" hl_lines="7 9-11 16"
{!> docs_src/getting_started/subscription/confluent/filter.py [ln:1-18] !}
```

=== "RabbitMQ"
```python linenums="1" hl_lines="10 17"
{!> docs_src/getting_started/subscription/rabbit/filter.py [ln:1-19] !}
```python linenums="1" hl_lines="7 9-11 16"
{!> docs_src/getting_started/subscription/rabbit/filter.py [ln:1-18] !}
```

=== "NATS"
```python linenums="1" hl_lines="10 17"
{!> docs_src/getting_started/subscription/nats/filter.py [ln:1-19] !}
```python linenums="1" hl_lines="7 9-11 16"
{!> docs_src/getting_started/subscription/nats/filter.py [ln:1-18] !}
```

=== "Redis"
```python linenums="1" hl_lines="10 17"
{!> docs_src/getting_started/subscription/redis/filter.py [ln:1-19] !}
```python linenums="1" hl_lines="7 9-11 16"
{!> docs_src/getting_started/subscription/redis/filter.py [ln:1-18] !}
```
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ otel = ["opentelemetry-sdk>=1.24.0,<2.0.0"]
optionals = ["faststream[rabbit,kafka,confluent,nats,redis,otel]"]

devdocs = [
"mkdocs-material==9.5.25",
"mkdocs-material==9.5.26",
"mkdocs-static-i18n==1.2.3",
"mdx-include==1.4.2",
"mkdocstrings[python]==0.25.1",
Expand Down Expand Up @@ -113,13 +113,13 @@ lint = [
"faststream[types]",
"ruff==0.4.8",
"bandit==1.7.8",
"semgrep==1.74.0",
"semgrep==1.75.0",
"codespell==2.3.0",
]

test-core = [
"coverage[toml]==7.5.3",
"pytest==8.2.1",
"pytest==8.2.2",
"pytest-asyncio==0.23.7",
"dirty-equals==0.7.1.post0",
"typing-extensions>=4.8.0,<4.12.1; python_version < '3.9'", # to fix dirty-equals
Expand Down

0 comments on commit c20629c

Please sign in to comment.