Skip to content

Commit 4a973b6

Browse files
authored
Create new ReactPyDjangoClient (#175)
- Move from JavaScript to TypeScript - Bumped the minimum `@reactpy/client` version to `0.3.1` - Create a Django-specific client - Minor refactoring to various bits of code - Bumped minimum Django version to `4.2`. - More customization for reconnection behavior through new settings! - `REACTPY_RECONNECT_INTERVAL` - `REACTPY_RECONNECT_MAX_INTERVAL` - `REACTPY_RECONNECT_MAX_RETRIES` - `REACTPY_RECONNECT_BACKOFF_MULTIPLIER`
1 parent cd0ebf5 commit 4a973b6

29 files changed

+672
-227
lines changed

Diff for: .github/workflows/publish-py.yml

+28-28
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
name: Publish Python
55

66
on:
7-
release:
8-
types: [published]
7+
release:
8+
types: [published]
99

1010
jobs:
11-
release-package:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: actions/checkout@v3
15-
- uses: actions/setup-node@v3
16-
with:
17-
node-version: "14.x"
18-
- name: Set up Python
19-
uses: actions/setup-python@v1
20-
with:
21-
python-version: "3.x"
22-
- name: Install NPM
23-
run: |
24-
npm install -g npm@7.22.0
25-
npm --version
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install -r requirements/build-pkg.txt
30-
- name: Build and publish
31-
env:
32-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
33-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
34-
run: |
35-
python -m build --sdist --wheel --outdir dist .
36-
twine upload dist/*
11+
release-package:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3
16+
with:
17+
node-version: "20.x"
18+
- name: Set up Python
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: "3.x"
22+
- name: Install NPM
23+
run: |
24+
npm install -g npm@latest
25+
npm --version
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r requirements/build-pkg.txt
30+
- name: Build and publish
31+
env:
32+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
33+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
34+
run: |
35+
python -m build --sdist --wheel --outdir dist .
36+
twine upload dist/*

Diff for: .github/workflows/publish-release-docs.yml

-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ jobs:
2020
git config user.name github-actions
2121
git config user.email [email protected]
2222
mike deploy --push --update-aliases ${{ github.event.release.name }} latest
23-
mike set-default --push latest

Diff for: .github/workflows/test-src.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v3
2121
- uses: actions/setup-node@v3
2222
with:
23-
node-version: "14.x"
23+
node-version: "20.x"
2424
- name: Use Python ${{ matrix.python-version }}
2525
uses: actions/setup-python@v4
2626
with:

Diff for: CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,26 @@ Using the following categories, list your changes in this order:
3636

3737
### Added
3838

39+
- More customization for reconnection behavior through new settings!
40+
- `REACTPY_RECONNECT_INTERVAL`
41+
- `REACTPY_RECONNECT_MAX_INTERVAL`
42+
- `REACTPY_RECONNECT_MAX_RETRIES`
43+
- `REACTPY_RECONNECT_BACKOFF_MULTIPLIER`
3944
- [ReactPy-Django docs](https://reactive-python.github.io/reactpy-django/) are now version controlled via [mike](https://github.com/jimporter/mike)!
4045

4146
### Changed
4247

4348
- Bumped the minimum ReactPy version to `1.0.2`.
4449
- Prettier websocket URLs for components that do not have sessions.
4550
- Template tag will now only validate `args`/`kwargs` if `settings.py:DEBUG` is enabled.
51+
- Bumped the minimum `@reactpy/client` version to `0.3.1`
52+
- Use TypeScript instead of JavaScript for this repository.
53+
- Bumped minimum Django version to `4.2`.
54+
- Note: ReactPy-Django will continue bumping minimum Django requirements to versions that increase async support. This "latest-only" trend will continue until Django has all async features that ReactPy benefits from. After this point, ReactPy-Django will begin supporting all maintained Django versions.
55+
56+
### Removed
57+
58+
- `settings.py:REACTPY_RECONNECT_MAX` is removed. See the docs for the new `REACTPY_RECONNECT_*` settings.
4659

4760
## [3.4.0] - 2023-08-18
4861

Diff for: docs/src/contribute/code.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ cd tests
4545
python manage.py runserver
4646
```
4747

48-
Navigate to `http://127.0.0.1:8000` to see if the tests are rendering correctly.
48+
Navigate to [`http://127.0.0.1:8000`](http://127.0.0.1:8000) to see if the tests are rendering correctly.
4949

5050
## GitHub Pull Request
5151

Diff for: docs/src/contribute/docs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Finally, to verify that everything is working properly, you can manually run the
3737
mkdocs serve
3838
```
3939

40-
Navigate to `http://127.0.0.1:8000` to view a preview of the documentation.
40+
Navigate to [`http://127.0.0.1:8000`](http://127.0.0.1:8000) to view a preview of the documentation.
4141

4242
## GitHub Pull Request
4343

Diff for: docs/src/features/settings.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ These are ReactPy-Django's default settings values. You can modify these values
2424
| --- | --- | --- | --- |
2525
| `REACTPY_CACHE` | `#!python "default"` | `#!python "my-reactpy-cache"` | Cache used to store ReactPy web modules. ReactPy benefits from a fast, well indexed cache.<br/>We recommend installing [`redis`](https://redis.io/) or [`python-diskcache`](https://grantjenks.com/docs/diskcache/tutorial.html#djangocache). |
2626
| `REACTPY_DATABASE` | `#!python "default"` | `#!python "my-reactpy-database"` | Database used to store ReactPy session data. ReactPy requires a multiprocessing-safe and thread-safe database.<br/>If configuring `REACTPY_DATABASE`, it is mandatory to use our database router like such:<br/>`#!python DATABASE_ROUTERS = ["reactpy_django.database.Router", ...]` |
27-
| `REACTPY_RECONNECT_MAX` | `#!python 259200` | `#!python 96000`, `#!python 60`, `#!python 0` | Maximum seconds between reconnection attempts before giving up.<br/>Use `#!python 0` to prevent reconnection. |
27+
| `REACTPY_SESSION_MAX_AGE` | `#!python 259200` | `#!python 0`, `#!python 60`, `#!python 96000` | Maximum seconds to store ReactPy session data, such as `args` and `kwargs` passed into your component template tag.<br/>Use `#!python 0` to not store any session data. |
2828
| `REACTPY_URL_PREFIX` | `#!python "reactpy/"` | `#!python "rp/"`, `#!python "render/reactpy/"` | The prefix to be used for all ReactPy websocket and HTTP URLs. |
2929
| `REACTPY_DEFAULT_QUERY_POSTPROCESSOR` | `#!python "reactpy_django.utils.django_query_postprocessor"` | `#!python "example_project.my_query_postprocessor"` | Dotted path to the default `reactpy_django.hooks.use_query` postprocessor function. |
3030
| `REACTPY_AUTH_BACKEND` | `#!python "django.contrib.auth.backends.ModelBackend"` | `#!python "example_project.auth.MyModelBackend"` | Dotted path to the Django authentication backend to use for ReactPy components. This is only needed if:<br/> 1. You are using `AuthMiddlewareStack` and...<br/> 2. You are using Django's `AUTHENTICATION_BACKENDS` setting and...<br/> 3. Your Django user model does not define a `backend` attribute. |
3131
| `REACTPY_BACKHAUL_THREAD` | `#!python False` | `#!python True` | Whether to render ReactPy components in a dedicated thread. This allows the webserver to process web traffic while during ReactPy rendering.<br/>Vastly improves throughput with web servers such as `hypercorn` and `uvicorn`. |
3232
| `REACTPY_DEFAULT_HOSTS` | `#!python None` | `#!python ["localhost:8000", "localhost:8001", "localhost:8002/subdir" ]` | The default host(s) that can render your ReactPy components. ReactPy will use these hosts in a round-robin fashion, allowing for easy distributed computing.<br/>You can use the `host` argument in your [template tag](../features/template-tag.md#component) as a manual override. |
33+
| `REACTPY_RECONNECT_INTERVAL` | `#!python 750` | `#!python 100`, `#!python 2500`, `#!python 6000` | Milliseconds between client reconnection attempts. This value will gradually increase if `REACTPY_RECONNECT_BACKOFF_MULTIPLIER` is greater than `#!python 1`. |
34+
| `REACTPY_RECONNECT_MAX_INTERVAL` | `#!python 60000` | `#!python 10000`, `#!python 25000`, `#!python 900000` | Maximum milliseconds between client reconnection attempts. This allows setting an upper bound on how high `REACTPY_RECONNECT_BACKOFF_MULTIPLIER` can increase the time between reconnection attempts. |
35+
| `REACTPY_RECONNECT_MAX_RETRIES` | `#!python 150` | `#!python 0`, `#!python 5`, `#!python 300` | Maximum number of reconnection attempts before the client gives up. |
36+
| `REACTPY_RECONNECT_BACKOFF_MULTIPLIER` | `#!python 1.25` | `#!python 1`, `#!python 1.5`, `#!python 3` | Multiplier for the time between client reconnection attempts. On each reconnection attempt, the `REACTPY_RECONNECT_INTERVAL` will be multiplied by this to increase the time between attempts. You can keep time between each reconnection the same by setting this to `#!python 1`. |
3337

3438
<!--config-details-end-->

Diff for: docs/src/get-started/run-webserver.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To test your new Django view, run the following command to start up a developmen
1616
python manage.py runserver
1717
```
1818

19-
Now you can navigate to your **Django project** URL that contains a ReactPy component, such as `http://127.0.0.1:8000/example/` ([_from the previous step_](./register-view.md)).
19+
Now you can navigate to your **Django project** URL that contains a ReactPy component, such as [`http://127.0.0.1:8000/example/`](http://127.0.0.1:8000/example/) ([_from the previous step_](./register-view.md)).
2020

2121
If you copy-pasted our example component, you will now see your component display "Hello World".
2222

Diff for: pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ warn_unused_configs = true
99
warn_redundant_casts = true
1010
warn_unused_ignores = true
1111
check_untyped_defs = true
12-
incremental = true
1312

1413
[tool.ruff.isort]
1514
known-first-party = ["src", "tests"]

Diff for: requirements/pkg-deps.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
channels >=4.0.0
2-
django >=4.1.0
2+
django >=4.2.0
33
reactpy >=1.0.2, <1.1.0
44
aiofile >=3.0
55
dill >=0.3.5

0 commit comments

Comments
 (0)