Skip to content

Commit 21cde5e

Browse files
authored
Update context documentation by removing broker examples
Removed broker examples for AIOKafka, Confluent, RabbitMQ, NATS, and Redis from the context documentation. Added information about setting a local context using the context manager.
1 parent 6f9423f commit 21cde5e

1 file changed

Lines changed: 6 additions & 58 deletions

File tree

docs/docs/en/getting-started/context.md

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -90,64 +90,6 @@ context = ContextRepo({"secret_str": "my-perfect-secret"})
9090
app = FastStream(context=context)
9191
```
9292

93-
And in brokers:
94-
95-
=== "AIOKafka"
96-
97-
```python
98-
from faststream.context import ContextRepo
99-
from faststream.kafka import KafkaBroker
100-
101-
context = ContextRepo({"secret_str": "my-perfect-secret"})
102-
broker = KafkaBroker(context=context)
103-
```
104-
105-
=== "Confluent"
106-
107-
```python
108-
from faststream.context import ContextRepo
109-
from faststream.confluent import KafkaBroker
110-
111-
context = ContextRepo({"secret_str": "my-perfect-secret"})
112-
broker = KafkaBroker(context=context)
113-
```
114-
115-
=== "RabbitMQ"
116-
117-
```python
118-
from faststream.context import ContextRepo
119-
from faststream.rabbit import RabbitBroker
120-
121-
context = ContextRepo({"secret_str": "my-perfect-secret"})
122-
broker = RabbitBroker(context=context)
123-
```
124-
125-
=== "NATS"
126-
127-
```python
128-
from faststream.context import ContextRepo
129-
from faststream.nats import NatsBroker
130-
131-
context = ContextRepo({"secret_str": "my-perfect-secret"})
132-
broker = NatsBroker(context=context)
133-
```
134-
135-
=== "Redis"
136-
137-
```python
138-
from faststream.context import ContextRepo
139-
from faststream.redis import RedisBroker
140-
141-
context = ContextRepo({"secret_str": "my-perfect-secret"})
142-
broker = RedisBroker(context=context)
143-
```
144-
145-
To remove a field from the context use the `reset_global` method:
146-
147-
```python
148-
context.reset_global("my_key")
149-
```
150-
15193
!!! tip
15294
It is important to keep in mind that the broker context takes precedence over the FastStream context.
15395

@@ -164,6 +106,12 @@ context.reset_global("my_key")
164106
assert data == "BROKER"
165107
```
166108

109+
To remove a field from the context use the `reset_global` method:
110+
111+
```python
112+
context.reset_global("my_key")
113+
```
114+
167115
## Local
168116

169117
To set a local context (available only within the message processing scope), use the context manager `scope`. It could me extremely uselful to fill context with additional options in [Middlewares](../middlewares/){.internal-link}

0 commit comments

Comments
 (0)