Skip to content

Commit 25635ea

Browse files
committed
update README.md to reflect redis changes
1 parent 908bc40 commit 25635ea

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,24 @@ This project is the alternative I wanted: **a simple, free, open-source relay**
1717

1818
A nice side-effect: you can keep the **same third-party webhook URL** (pointing at your production app) and **toggle forwarding on/off** with a config change (e.g. `enabled=False`) or by simply connecting/disconnecting the dev client—no redeploy and no “update webhook URL” dance.
1919

20+
**Single instance vs multiple:** With one FastAPI instance in production, the default setup works with no extra infrastructure. If you run multiple instances behind a load balancer, add `redis_url` and install the `[redis]` extra so webhook requests routed to any instance still reach your dev client.
21+
2022
### Install
2123

2224
```
2325
pip install fastapi-dev-proxy
2426
```
2527

28+
**Multiple instances (load balanced):** If you run more than one FastAPI instance in production (e.g. behind a load balancer), install the optional Redis dependency so webhook requests can reach the dev client no matter which instance receives them:
29+
30+
```
31+
pip install fastapi-dev-proxy[redis]
32+
```
33+
2634
### Server integration
2735

36+
**Single instance** (default—no extra infrastructure):
37+
2838
```python
2939
from fastapi import FastAPI, Response
3040
from fastapi_dev_proxy.server import RelayManager
@@ -37,6 +47,29 @@ async def sms_webhook() -> Response:
3747
return Response(status_code=200)
3848
```
3949

50+
**Multiple instances** (behind a load balancer): Pass `redis_url` so instances coordinate via Redis. The dev client can connect to any instance; webhook requests to any instance are forwarded correctly:
51+
52+
```python
53+
import os
54+
from fastapi import FastAPI, Response
55+
from fastapi_dev_proxy.server import RelayManager
56+
57+
app = FastAPI()
58+
relay = RelayManager(
59+
app=app,
60+
token="secret",
61+
enabled=True,
62+
timeout_seconds=25,
63+
redis_url=os.environ.get("REDIS_URL"), # e.g. redis://localhost:6379/0
64+
)
65+
66+
@app.post("/webhook/sms")
67+
async def sms_webhook() -> Response:
68+
return Response(status_code=200)
69+
```
70+
71+
With `redis_url=None` (the default), behavior is unchanged: single-instance only. Set `redis_url` only when you run multiple instances.
72+
4073
If you prefer, you can create the relay first and call `relay.install(app)` later.
4174

4275
When installed (default `path_prefix` is `/fastapi-dev-proxy`), the relay registers:

0 commit comments

Comments
 (0)