Skip to content

Commit cf8f141

Browse files
authored
Add FastAPI and FastStream examples to Quickstart section (#107)
1 parent 6df6c75 commit cf8f141

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,66 @@ application: litestar.Litestar = LitestarBootstrapper(settings).bootstrap()
138138

139139
This approach will provide you with an application that has all the essential instruments already set up for you.
140140

141+
### FastAPI
142+
143+
```python
144+
import fastapi
145+
146+
from microbootstrap import FastApiSettings
147+
from microbootstrap.bootstrappers.fastapi import FastApiBootstrapper
148+
149+
150+
class YourSettings(FastApiSettings):
151+
# General settings
152+
service_debug: bool = False
153+
service_name: str = "my-awesome-service"
154+
155+
# Sentry settings
156+
sentry_dsn: str = "your-sentry-dsn"
157+
158+
# Prometheus settings
159+
prometheus_metrics_path: str = "/my-path"
160+
161+
# Opentelemetry settings
162+
opentelemetry_container_name: str = "your-container"
163+
opentelemetry_endpoint: str = "/opentelemetry-endpoint"
164+
165+
166+
settings = YourSettings()
167+
168+
application: fastapi.FastAPI = FastApiBootstrapper(settings).bootstrap()
169+
```
170+
171+
### FastStream
172+
173+
```python
174+
from faststream.asgi import AsgiFastStream
175+
176+
from microbootstrap import FastStreamSettings
177+
from microbootstrap.bootstrappers.faststream import FastStreamBootstrapper
178+
179+
180+
class YourSettings(FastStreamSettings):
181+
# General settings
182+
service_debug: bool = False
183+
service_name: str = "my-awesome-service"
184+
185+
# Sentry settings
186+
sentry_dsn: str = "your-sentry-dsn"
187+
188+
# Prometheus settings
189+
prometheus_metrics_path: str = "/my-path"
190+
191+
# Opentelemetry settings
192+
opentelemetry_container_name: str = "your-container"
193+
opentelemetry_endpoint: str = "/opentelemetry-endpoint"
194+
195+
196+
settings = YourSettings()
197+
198+
application: AsgiFastStream = FastStreamBootstrapper(settings).bootstrap()
199+
```
200+
141201
## Settings
142202

143203
The settings object is the core of microbootstrap.

0 commit comments

Comments
 (0)