You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contributing.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
We welcome contributions from the community to help improve FastAPI Maintenance.
4
4
5
-
First, you might want to see the basic ways to [help FastAPI Maintenance package and get help](help.md).
5
+
First, you might want to see the basic ways to [help FastAPI Maintenance project and get help](help.md).
6
6
7
7
## Developing
8
8
@@ -49,7 +49,7 @@ We use pytest for testing. To run the tests and generate coverage reports:
49
49
bash scripts/test.sh
50
50
```
51
51
52
-
This command generates a directory `./htmlcov/`, if you open the file `./htmlcov/index.html` in your browser, you can explore interactively the regions of code that are covered by the tests, and notice if there is any region missing.
52
+
This command generates a directory `./htmlcov/`. Open the file `./htmlcov/index.html` in your browser to interactively explore which regions of code are covered by tests and identify any missing coverage.
Copy file name to clipboardExpand all lines: docs/tutorial/advanced-usage.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
# Advanced Usage
2
2
3
-
This section covers advanced usage patterns and integration scenarios for the FastAPI Maintenance package. These advanced usage patterns demonstrate how FastAPI Maintenance can be integrated into complex systems and workflows.
3
+
This section covers advanced usage patterns and integration scenarios, demonstrating how FastAPI Maintenance can be integrated into complex systems and workflows.
4
4
5
5
## Combining Multiple Features
6
6
7
7
You can combine various features of FastAPI Maintenance for sophisticated maintenance scenarios:
8
8
9
9
```python
10
-
from fastapi import FastAPI, Request, Depends
10
+
from fastapi import FastAPI, Request
11
11
from fastapi.responses import JSONResponse
12
12
from fastapi_maintenance import (
13
13
MaintenanceModeMiddleware,
@@ -62,6 +62,8 @@ async def update_system():
62
62
You can use FastAPI's events to configure maintenance mode during application startup and shutdown:
63
63
64
64
```python
65
+
from contextlib import asynccontextmanager
66
+
65
67
from fastapi import FastAPI
66
68
from fastapi_maintenance import (
67
69
MaintenanceModeMiddleware,
@@ -72,18 +74,16 @@ from fastapi_maintenance import (
Copy file name to clipboardExpand all lines: docs/tutorial/backends.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Backend Options
2
2
3
-
FastAPI Maintenance provides flexible backend storage options for managing the maintenance mode state. This allows you to store the maintenance mode state in different ways depending on your application's needs.
3
+
FastAPI Maintenance provides flexible backend storage options for managing the maintenance mode state. This allows you to store and read the maintenance mode state in different ways depending on your application's needs.
4
4
5
5
## Available Backends
6
6
7
7
The package currently includes two built-in backend options:
8
8
9
-
1.**Environment Variable Backend** (default): Uses environment variables to store the maintenance mode state
9
+
1.**Environment Variable Backend** (default): Reads the maintenance mode state from environment variables
10
10
2.**Local File Backend**: Uses a local file to store the maintenance mode state
11
11
12
12
## Environment Variable Backend
@@ -41,7 +41,7 @@ The environment variable backend is **read-only** at runtime. This means:
41
41
42
42
- You can only set the maintenance mode state *before* starting your application.
43
43
- Direct calls to `set_maintenance_mode()` will log a warning and have no effect.
44
-
- However, context manager `maintenance_mode_on()`**will work as expected for the duration of the context block**. They achieve this by using a temporary, in-memory override of the maintenance state. The actual environment variable is not changed. This allows you to temporarily simulate maintenance mode changes even with the environment variable backend.
44
+
- However, context manager `maintenance_mode_on()`**will work as expected for the duration of the context block**. It achieves this by using a temporary, in-memory override of the maintenance state. The actual environment variable is not changed. This allows you to temporarily simulate maintenance mode changes even with the environment variable backend.
45
45
46
46
Use this backend when you primarily manage maintenance mode state externally (e.g., via deployment scripts or orchestration tools) but still want the flexibility of temporary overrides within your code using context managers.
You can nest the `maintenance_mode_on` context manager. When nesting, the innermost context will maintain the state established by the outer context:
116
+
You can nest the `maintenance_mode_on` context manager. When nesting, maintenance mode remains ON throughout all nested contexts until the outermost context exits:
119
117
120
118
```python
119
+
from fastapi_maintenance import maintenance_mode_on, get_maintenance_mode
0 commit comments