django-pg-sse 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. django_pg_sse-0.1.0/.github/dependabot.yml +30 -0
  2. django_pg_sse-0.1.0/.github/workflows/release.yml +178 -0
  3. django_pg_sse-0.1.0/.github/workflows/test.yml +224 -0
  4. django_pg_sse-0.1.0/.gitignore +91 -0
  5. django_pg_sse-0.1.0/.pre-commit-config.yaml +51 -0
  6. django_pg_sse-0.1.0/.readthedocs.yml +17 -0
  7. django_pg_sse-0.1.0/CHANGELOG.md +19 -0
  8. django_pg_sse-0.1.0/CONTRIBUTING.md +33 -0
  9. django_pg_sse-0.1.0/LICENSE +18 -0
  10. django_pg_sse-0.1.0/PKG-INFO +277 -0
  11. django_pg_sse-0.1.0/README.md +248 -0
  12. django_pg_sse-0.1.0/docs/api.md +49 -0
  13. django_pg_sse-0.1.0/docs/changelog.md +2 -0
  14. django_pg_sse-0.1.0/docs/conf.py +44 -0
  15. django_pg_sse-0.1.0/docs/deployment.md +269 -0
  16. django_pg_sse-0.1.0/docs/index.md +12 -0
  17. django_pg_sse-0.1.0/docs/requirements.txt +9 -0
  18. django_pg_sse-0.1.0/docs/settings.md +103 -0
  19. django_pg_sse-0.1.0/mise.toml +53 -0
  20. django_pg_sse-0.1.0/pyproject.toml +137 -0
  21. django_pg_sse-0.1.0/src/django_pg_sse/__init__.py +24 -0
  22. django_pg_sse-0.1.0/src/django_pg_sse/apps.py +39 -0
  23. django_pg_sse-0.1.0/src/django_pg_sse/checks.py +105 -0
  24. django_pg_sse-0.1.0/src/django_pg_sse/conf.py +31 -0
  25. django_pg_sse-0.1.0/src/django_pg_sse/hub.py +424 -0
  26. django_pg_sse-0.1.0/src/django_pg_sse/management/__init__.py +1 -0
  27. django_pg_sse-0.1.0/src/django_pg_sse/management/commands/__init__.py +1 -0
  28. django_pg_sse-0.1.0/src/django_pg_sse/management/commands/prune_stream_events.py +29 -0
  29. django_pg_sse-0.1.0/src/django_pg_sse/messages.py +128 -0
  30. django_pg_sse-0.1.0/src/django_pg_sse/migrations/0001_initial.py +27 -0
  31. django_pg_sse-0.1.0/src/django_pg_sse/migrations/__init__.py +0 -0
  32. django_pg_sse-0.1.0/src/django_pg_sse/models.py +27 -0
  33. django_pg_sse-0.1.0/src/django_pg_sse/permissions.py +19 -0
  34. django_pg_sse-0.1.0/src/django_pg_sse/publish.py +154 -0
  35. django_pg_sse-0.1.0/src/django_pg_sse/py.typed +0 -0
  36. django_pg_sse-0.1.0/src/django_pg_sse/signals.py +25 -0
  37. django_pg_sse-0.1.0/src/django_pg_sse/urls.py +11 -0
  38. django_pg_sse-0.1.0/src/django_pg_sse/views.py +206 -0
  39. django_pg_sse-0.1.0/tests/__init__.py +0 -0
  40. django_pg_sse-0.1.0/tests/settings.py +40 -0
  41. django_pg_sse-0.1.0/tests/test_app.py +97 -0
  42. django_pg_sse-0.1.0/tests/test_docs.py +64 -0
  43. django_pg_sse-0.1.0/tests/test_prune.py +43 -0
  44. django_pg_sse-0.1.0/tests/test_publish.py +218 -0
  45. django_pg_sse-0.1.0/tests/test_stream.py +1073 -0
  46. django_pg_sse-0.1.0/tests/urls.py +5 -0
  47. django_pg_sse-0.1.0/tox.ini +31 -0
  48. django_pg_sse-0.1.0/uv.lock +432 -0
@@ -0,0 +1,30 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ cooldown:
8
+ default-days: 7
9
+
10
+ - package-ecosystem: "uv"
11
+ directory: "/"
12
+ schedule:
13
+ interval: "weekly"
14
+ cooldown:
15
+ default-days: 7
16
+ groups:
17
+ python-deps:
18
+ patterns:
19
+ - "*"
20
+
21
+ - package-ecosystem: "pip"
22
+ directory: "/docs"
23
+ schedule:
24
+ interval: "weekly"
25
+ cooldown:
26
+ default-days: 7
27
+ groups:
28
+ docs-deps:
29
+ patterns:
30
+ - "*"
@@ -0,0 +1,178 @@
1
+ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2
+
3
+ on: push
4
+
5
+ concurrency:
6
+ group: ${{ github.workflow }}-${{ github.ref }}
7
+ cancel-in-progress: true
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ env:
13
+ # Change these for your project's URLs
14
+ PYPI_URL: https://pypi.org/p/django-pg-sse
15
+ PYPI_TEST_URL: https://test.pypi.org/p/django-pg-sse
16
+
17
+ jobs:
18
+
19
+ build:
20
+ name: Build distribution 📦
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25
+ with:
26
+ persist-credentials: false
27
+ - name: Set up Python
28
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
29
+ with:
30
+ python-version: "3.x"
31
+ - name: Install pypa/build
32
+ run:
33
+ python3 -m pip install build --user
34
+ - name: Build a binary wheel and a source tarball
35
+ run: python3 -m build
36
+ - name: Store the distribution packages
37
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
38
+ with:
39
+ name: python-package-distributions
40
+ path: dist/
41
+ - name: Extract changelog for tagged release
42
+ if: startsWith(github.ref, 'refs/tags/')
43
+ env:
44
+ REF_NAME: ${{ github.ref_name }}
45
+ run: |
46
+ VERSION="${REF_NAME#v}"
47
+ awk -v ver="$VERSION" '
48
+ # A literal match: "## 0.1.1" or "## 0.1.1 (date)", never "## 0.1.10".
49
+ $0 == "## " ver || index($0, "## " ver " ") == 1 { found=1; next }
50
+ found && /^## / { exit }
51
+ found { print }
52
+ ' CHANGELOG.md > release-notes.md
53
+ if [[ ! -s release-notes.md ]]; then
54
+ echo "::error::No changelog section found for version ${VERSION}."
55
+ echo "::error::Did you forget to rename '## Unreleased' in CHANGELOG.md before tagging?"
56
+ exit 1
57
+ fi
58
+ echo "--- Extracted release notes ---"
59
+ cat release-notes.md
60
+ - name: Upload release notes
61
+ if: startsWith(github.ref, 'refs/tags/')
62
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
63
+ with:
64
+ name: release-notes
65
+ path: release-notes.md
66
+
67
+ publish-to-pypi:
68
+ name: >-
69
+ Publish Python 🐍 distribution 📦 to PyPI
70
+ if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
71
+ # TestPyPI first: the upload to PyPI cannot be undone, so a broken artifact
72
+ # has to fail somewhere reversible before it gets there.
73
+ needs:
74
+ - build
75
+ - publish-to-testpypi
76
+ runs-on: ubuntu-latest
77
+ environment:
78
+ name: pypi
79
+ url: ${{ env.PYPI_URL }}
80
+ permissions:
81
+ id-token: write # IMPORTANT: mandatory for trusted publishing
82
+ steps:
83
+ - name: Download all the dists
84
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
85
+ with:
86
+ name: python-package-distributions
87
+ path: dist/
88
+ - name: Publish distribution 📦 to PyPI
89
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
90
+
91
+ github-release:
92
+ name: >-
93
+ Sign the Python 🐍 distribution 📦 with Sigstore
94
+ and upload them to GitHub Release
95
+ needs:
96
+ - publish-to-pypi
97
+ runs-on: ubuntu-latest
98
+
99
+ permissions:
100
+ contents: write # IMPORTANT: mandatory for making GitHub Releases
101
+ id-token: write # IMPORTANT: mandatory for sigstore
102
+
103
+ steps:
104
+ - name: Download all the dists
105
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
106
+ with:
107
+ name: python-package-distributions
108
+ path: dist/
109
+ - name: Download release notes
110
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
111
+ with:
112
+ name: release-notes
113
+ - name: Sign the dists with Sigstore
114
+ uses: sigstore/gh-action-sigstore-python@790bc6befb9d733738f18d8f895854b453640ec9 # v3.5.0
115
+ with:
116
+ inputs: >-
117
+ ./dist/*.tar.gz
118
+ ./dist/*.whl
119
+ - name: Create GitHub Release
120
+ env:
121
+ GITHUB_TOKEN: ${{ github.token }}
122
+ REF_NAME: ${{ github.ref_name }}
123
+ REPO: ${{ github.repository }}
124
+ run: >-
125
+ gh release create
126
+ "$REF_NAME"
127
+ --repo "$REPO"
128
+ --notes-file release-notes.md
129
+ - name: Upload artifact signatures to GitHub Release
130
+ env:
131
+ GITHUB_TOKEN: ${{ github.token }}
132
+ REF_NAME: ${{ github.ref_name }}
133
+ REPO: ${{ github.repository }}
134
+ # Upload to GitHub Release using the `gh` CLI.
135
+ # `dist/` contains the built packages, and the
136
+ # sigstore-produced signatures and certificates.
137
+ run: >-
138
+ gh release upload
139
+ "$REF_NAME" dist/**
140
+ --repo "$REPO"
141
+
142
+ test:
143
+ name: Test
144
+ if: startsWith(github.ref, 'refs/tags/')
145
+ # A called workflow gets at most these; GitHub rejects the file if a job there asks for more.
146
+ permissions:
147
+ contents: read
148
+ actions: read # the zizmor job reads workflow definitions
149
+ security-events: write # the zizmor job uploads SARIF results
150
+ uses: ./.github/workflows/test.yml
151
+
152
+ publish-to-testpypi:
153
+ name: Publish Python 🐍 distribution 📦 to TestPyPI
154
+ if: startsWith(github.ref, 'refs/tags/') # only publish to TestPyPI on tag pushes
155
+ # PyPI follows TestPyPI, so a red suite stops both uploads.
156
+ needs:
157
+ - build
158
+ - test
159
+ runs-on: ubuntu-latest
160
+
161
+ environment:
162
+ name: testpypi
163
+ url: ${{ env.PYPI_TEST_URL }}
164
+
165
+ permissions:
166
+ id-token: write # IMPORTANT: mandatory for trusted publishing
167
+
168
+ steps:
169
+ - name: Download all the dists
170
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
171
+ with:
172
+ name: python-package-distributions
173
+ path: dist/
174
+ - name: Publish distribution 📦 to TestPyPI
175
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
176
+ with:
177
+ repository-url: https://test.pypi.org/legacy/
178
+ skip-existing: true
@@ -0,0 +1,224 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ # release.yml runs the suite before it publishes a tag.
9
+ workflow_call:
10
+
11
+ # A literal prefix: in a called workflow github.workflow names the caller,
12
+ # whose own group would cancel this run.
13
+ concurrency:
14
+ group: test-${{ github.ref }}
15
+ cancel-in-progress: true
16
+
17
+ permissions:
18
+ contents: read
19
+
20
+ jobs:
21
+ lint:
22
+ name: Lint
23
+ runs-on: ubuntu-latest
24
+
25
+ # pre-commit pins its hook environments to 3.13 (default_language_version),
26
+ # and the linters only ever need one interpreter.
27
+ env:
28
+ MISE_PYTHON_VERSION: "3.13"
29
+
30
+ steps:
31
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32
+ with:
33
+ persist-credentials: false
34
+
35
+ - name: Set up mise
36
+ uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
37
+ with:
38
+ install: true
39
+ cache: true
40
+ # Distinct from the test jobs: this one also installs pre-commit, so
41
+ # sharing their key would hand them a cache missing a tool. The
42
+ # version belongs in the key too, or bumping it later restores a
43
+ # cache holding the old interpreter and never re-saves.
44
+ cache_key: "lint-{{default}}-{{env.MISE_PYTHON_VERSION}}"
45
+
46
+ - name: Cache pre-commit hooks
47
+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
48
+ with:
49
+ path: ~/.cache/pre-commit
50
+ key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
51
+ restore-keys: pre-commit-${{ runner.os }}-
52
+
53
+ - name: Cache uv downloads
54
+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
55
+ with:
56
+ path: ~/.cache/uv
57
+ key: uv-${{ runner.os }}-lint-${{ hashFiles('uv.lock') }}
58
+ restore-keys: uv-${{ runner.os }}-lint-
59
+
60
+ # basedpyright resolves imports through .venv (see [tool.pyright] in
61
+ # pyproject.toml). Without this step it reports every import as missing.
62
+ # --locked, unlike `mise run bootstrap`: a uv.lock that has drifted from
63
+ # pyproject.toml should fail the job, not be silently re-resolved into
64
+ # something uv-audit then audits instead of the committed lock.
65
+ - name: Install dependencies
66
+ run: uv sync --locked
67
+
68
+ # uv-audit checks uv.lock against the published advisories, so a new one
69
+ # can turn an unrelated pull request red. That is deliberate: it is how we
70
+ # hear about it. Fix the lock rather than skipping the hook.
71
+ - name: Run pre-commit
72
+ run: mise run lint
73
+
74
+ build:
75
+ name: Test (Python ${{ matrix.python-version }})
76
+ runs-on: ubuntu-latest
77
+ strategy:
78
+ matrix:
79
+ python-version: ["3.12", "3.13", "3.14", "3.15"]
80
+
81
+ # Job-scoped so every step resolves the same interpreter, not just the
82
+ # install step.
83
+ env:
84
+ POSTGRES_HOST: localhost
85
+ POSTGRES_USER: postgres
86
+ POSTGRES_PASSWORD: postgres
87
+ MISE_PYTHON_VERSION: ${{ matrix.python-version }}
88
+ # pre-commit too, unlike the lint job: this one never runs it.
89
+ MISE_DISABLE_TOOLS: pre-commit
90
+
91
+ # The suite needs PostgreSQL: LISTEN/NOTIFY and advisory locks exist nowhere else.
92
+ services:
93
+ postgres:
94
+ image: postgres:18
95
+ env:
96
+ POSTGRES_PASSWORD: postgres
97
+ ports:
98
+ - 5432:5432
99
+ options: >-
100
+ --health-cmd pg_isready
101
+ --health-interval 5s
102
+ --health-timeout 5s
103
+ --health-retries 10
104
+ steps:
105
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
106
+ with:
107
+ persist-credentials: false
108
+
109
+ - name: Set up mise
110
+ uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
111
+ with:
112
+ install: true
113
+ cache: true
114
+ # The default key ignores MISE_PYTHON_VERSION, so every matrix job
115
+ # would share one entry holding a single Python.
116
+ cache_key: "{{default}}-{{env.MISE_PYTHON_VERSION}}"
117
+
118
+ - name: Cache uv downloads
119
+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
120
+ with:
121
+ path: ~/.cache/uv
122
+ key: uv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
123
+ restore-keys: uv-${{ runner.os }}-${{ matrix.python-version }}-
124
+
125
+ - name: Test with tox
126
+ run: mise run test-all
127
+
128
+ coverage:
129
+ name: Coverage
130
+ runs-on: ubuntu-latest
131
+
132
+ # The tox matrix runs pytest without --cov, so the fail_under floor in
133
+ # pyproject.toml would otherwise be a local convention nothing enforces.
134
+ # One interpreter is enough: the floor is about the suite, not the matrix.
135
+ env:
136
+ POSTGRES_HOST: localhost
137
+ POSTGRES_USER: postgres
138
+ POSTGRES_PASSWORD: postgres
139
+ MISE_PYTHON_VERSION: "3.13"
140
+ MISE_DISABLE_TOOLS: pre-commit
141
+
142
+ # The suite needs PostgreSQL: LISTEN/NOTIFY and advisory locks exist nowhere else.
143
+ services:
144
+ postgres:
145
+ image: postgres:18
146
+ env:
147
+ POSTGRES_PASSWORD: postgres
148
+ ports:
149
+ - 5432:5432
150
+ options: >-
151
+ --health-cmd pg_isready
152
+ --health-interval 5s
153
+ --health-timeout 5s
154
+ --health-retries 10
155
+ steps:
156
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
157
+ with:
158
+ persist-credentials: false
159
+
160
+ - name: Set up mise
161
+ uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
162
+ with:
163
+ install: true
164
+ cache: true
165
+ cache_key: "coverage-{{default}}-{{env.MISE_PYTHON_VERSION}}"
166
+
167
+ - name: Cache uv downloads
168
+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
169
+ with:
170
+ path: ~/.cache/uv
171
+ key: uv-${{ runner.os }}-coverage-${{ hashFiles('uv.lock') }}
172
+ restore-keys: uv-${{ runner.os }}-coverage-
173
+
174
+ - name: Install dependencies
175
+ run: uv sync --locked
176
+
177
+ - name: Run the suite with coverage
178
+ run: mise run test
179
+
180
+ docs:
181
+ name: Docs
182
+ runs-on: ubuntu-latest
183
+
184
+ # Sphinx reports a missing reference or an unresolvable include as a warning
185
+ # and publishes anyway. mise run build-docs passes -W, so those fail here.
186
+ env:
187
+ MISE_PYTHON_VERSION: "3.13"
188
+ MISE_DISABLE_TOOLS: pre-commit
189
+
190
+ steps:
191
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
192
+ with:
193
+ persist-credentials: false
194
+
195
+ - name: Set up mise
196
+ uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0
197
+ with:
198
+ install: true
199
+ cache: true
200
+ cache_key: "docs-{{default}}-{{env.MISE_PYTHON_VERSION}}"
201
+
202
+ - name: Cache uv downloads
203
+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
204
+ with:
205
+ path: ~/.cache/uv
206
+ key: uv-${{ runner.os }}-docs-${{ hashFiles('docs/requirements.txt', 'uv.lock') }}
207
+ restore-keys: uv-${{ runner.os }}-docs-
208
+
209
+ - name: Build the docs
210
+ run: mise run build-docs
211
+
212
+ zizmor:
213
+ name: Audit workflows (zizmor)
214
+ runs-on: ubuntu-latest
215
+ permissions:
216
+ contents: read
217
+ actions: read # zizmor-action reads workflow definitions
218
+ security-events: write # upload SARIF results to code scanning
219
+ steps:
220
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
221
+ with:
222
+ persist-credentials: false
223
+
224
+ - uses: zizmorcore/zizmor-action@85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e # v0.7.1
@@ -0,0 +1,91 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # Installer logs
30
+ pip-log.txt
31
+ pip-delete-this-directory.txt
32
+
33
+ # Unit test / coverage reports
34
+ htmlcov/
35
+ .tox/
36
+ .nox/
37
+ .coverage
38
+ .coverage.*
39
+ .cache
40
+ nosetests.xml
41
+ coverage.xml
42
+ *.cover
43
+ *.py,cover
44
+ .hypothesis/
45
+ .pytest_cache/
46
+ cover/
47
+
48
+ # Translations
49
+ *.mo
50
+ *.pot
51
+
52
+ # Django
53
+ *.log
54
+ local_settings.py
55
+ db.sqlite3*
56
+ static/
57
+
58
+ # Environments
59
+ .env
60
+ .venv
61
+ env/
62
+ venv/
63
+ ENV/
64
+ env.bak/
65
+ venv.bak/
66
+
67
+ # mkdocs
68
+ /site
69
+ docs/_build/
70
+
71
+ # ruff
72
+ .ruff_cache/
73
+
74
+ # IDE
75
+ .idea/
76
+ .vscode/
77
+
78
+ # macOS
79
+ .DS_Store
80
+
81
+ # Local tool config
82
+ mise.local.toml
83
+
84
+ # Local agent and tracker state (AGENTS.md and CLAUDE.md are tracked)
85
+ CLAUDE.local.md
86
+ .claude/
87
+ .beans.yml
88
+ .beans/
89
+
90
+ # Local environment
91
+ .env
@@ -0,0 +1,51 @@
1
+ default_language_version:
2
+ python: python3.13
3
+
4
+ repos:
5
+ - repo: https://github.com/pre-commit/pre-commit-hooks
6
+ rev: v6.0.0
7
+ hooks:
8
+ - id: trailing-whitespace
9
+ - id: end-of-file-fixer
10
+ - id: check-yaml
11
+ - id: check-toml
12
+ - id: check-added-large-files
13
+ - id: check-merge-conflict
14
+ - id: check-case-conflict
15
+ - id: check-symlinks
16
+ - id: check-json
17
+
18
+ - repo: https://github.com/charliermarsh/ruff-pre-commit
19
+ rev: "v0.15.10"
20
+ hooks:
21
+ - id: ruff
22
+ - id: ruff-format
23
+
24
+ - repo: https://github.com/asottile/pyupgrade
25
+ rev: v3.21.2
26
+ hooks:
27
+ - id: pyupgrade
28
+ args: [--py312-plus]
29
+
30
+ - repo: https://github.com/adamchainz/django-upgrade
31
+ rev: "1.30.0"
32
+ hooks:
33
+ - id: django-upgrade
34
+ args: [--target-version, "5.2"]
35
+
36
+ - repo: https://github.com/adamchainz/djade-pre-commit
37
+ rev: "1.9.0"
38
+ hooks:
39
+ - id: djade
40
+ args: [--target-version, "5.2"]
41
+
42
+ - repo: https://github.com/astral-sh/uv-pre-commit
43
+ rev: 0.13.6
44
+ hooks:
45
+ - id: uv-audit
46
+ args: [--preview-features, audit-command]
47
+
48
+ - repo: https://github.com/DetachHead/basedpyright-pre-commit-mirror
49
+ rev: 1.40.2
50
+ hooks:
51
+ - id: basedpyright
@@ -0,0 +1,17 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-24.04
5
+ tools:
6
+ python: "3.13"
7
+
8
+ sphinx:
9
+ configuration: docs/conf.py
10
+ fail_on_warning: true
11
+
12
+ python:
13
+ install:
14
+ - requirements: docs/requirements.txt
15
+ # autodoc imports the package.
16
+ - method: pip
17
+ path: .
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-11-16)
4
+
5
+ ### 🚀 Features
6
+ - **`broadcast(topic, data, event="")`** sends HTML, or any text in a named event, to the open server-sent event streams of a topic after the transaction commits.
7
+ - **`broadcast_json(topic, value, event=...)`** sends JSON in a named event for client code.
8
+ - **`abroadcast()`, `abroadcast_json()` and `aclose_streams()`** do the same from async code.
9
+ - **One stream per page** for several topics, with `Last-Event-ID` replay from stored events.
10
+ Event ids are signed for the stream's user, session and topics, so a client cannot pick its own replay start.
11
+ - **`close_streams(user=..., session=...)`** ends streams after access is taken away; logging out closes the streams of that session.
12
+ - **`stream_opened` and `stream_closed` signals** report the lifecycle of each stream, such as for presence or metrics.
13
+ - **System checks** for PostgreSQL, the `PG_SSE` values and the authentication middleware.
14
+ - **`PG_SSE["DATABASE"]`** gives the hub its own alias, such as one that bypasses a PgBouncer in transaction mode.
15
+ - **Timeouts** for the hub's queries (`QUERY_TIMEOUT`, 30 s) and connects (10 s), and `tcp_user_timeout` on Linux, so a failover holds a worker for a bounded time.
16
+ - **Keepalives** after 15 quiet seconds, also while a stream opens, and the `X-Accel-Buffering: no` header for nginx.
17
+ - **Reserved topics**: the stream view and `broadcast()` refuse topics starting with `_`.
18
+ - **`prune_stream_events`** deletes events older than the retention.
19
+ - **Documentation** on Read the Docs, with settings, a deployment guide and an API reference.
@@ -0,0 +1,33 @@
1
+ # Contributing
2
+
3
+ Bug reports and pull requests are welcome. Keep each submission to one topic, and describe what
4
+ you did, what you expected and what happened instead.
5
+
6
+ ## Development setup
7
+
8
+ The project uses [mise](https://mise.jdx.dev) for the toolchain and [uv](https://docs.astral.sh/uv/)
9
+ for dependencies. The tests need a running PostgreSQL server.
10
+
11
+ ```shell
12
+ mise trust
13
+ mise run bootstrap # install dependencies into .venv
14
+ createdb django_pg_sse
15
+ mise run test # pytest with coverage
16
+ mise run test-all # the Python and Django matrix via tox
17
+ mise run lint # pre-commit, including basedpyright in strict mode
18
+ ```
19
+
20
+ `tests/settings.py` connects to the local Unix socket as the current user. Set `POSTGRES_HOST`,
21
+ `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_PORT` or `POSTGRES_DB` to use another server.
22
+
23
+ ## Changes
24
+
25
+ - Write a failing test first, then the change.
26
+ - Use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages.
27
+ - Add a line to the `## Unreleased` section of `CHANGELOG.md` for every user-visible change.
28
+
29
+ ## Releases
30
+
31
+ Rename `## Unreleased` in `CHANGELOG.md` to the version and date, commit, and push a tag such as
32
+ `v0.1.0`. The release workflow publishes to TestPyPI, then PyPI, and creates a signed GitHub
33
+ release with that changelog section.
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Oliver Andrich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction,
7
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
8
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
15
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
17
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.