Skip to content

Commit 8fef141

Browse files
authored
feat:support for valkey (#161)
1 parent 8a09f51 commit 8fef141

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2013
-1335
lines changed

.github/actions/test-coverage/action.yml

+1
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ runs:
4747
repo-token: ${{ inputs.repoToken }}
4848
repo-token-user-login: 'github-actions[bot]'
4949
allow-repeats: true
50+
update-only: true

.github/workflows/publish.yml

+65-24
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,82 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
9-
name: Upload Python Package
1+
name: Release
102

113
on:
124
release:
135
types: [published]
6+
push:
7+
tags:
8+
- '*.*.*'
9+
10+
env:
11+
# Change these for your project's URLs
12+
PYPI_URL: https://pypi.org/p/django-tasks-scheduler
13+
PYPI_TEST_URL: https://test.pypi.org/p/django-tasks-scheduler
1414

1515
jobs:
16-
publish:
16+
17+
build:
18+
name: Build distribution 📦
1719
runs-on: ubuntu-latest
18-
permissions:
19-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
2020

2121
steps:
2222
- uses: actions/checkout@v4
23-
2423
- name: Set up Python
2524
uses: actions/setup-python@v5
2625
with:
27-
python-version: '3.12'
28-
cache-dependency-path: poetry.lock
26+
python-version: "3.12"
27+
- name: Install pypa/build
28+
run:
29+
python3 -m pip install build --user
30+
- name: Build a binary wheel and a source tarball
31+
run: python3 -m build
32+
- name: Store the distribution packages
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: python-package-distributions
36+
path: dist/
2937

30-
- name: Install dependencies
31-
run: |
32-
python -m pip install --upgrade pip
33-
pip install build
38+
publish-to-pypi:
39+
name: >-
40+
Publish Python 🐍 distribution 📦 to PyPI
41+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
42+
needs:
43+
- build
44+
runs-on: ubuntu-latest
45+
environment:
46+
name: pypi
47+
url: ${{ env.PYPI_URL }}
48+
permissions:
49+
id-token: write # IMPORTANT: mandatory for trusted publishing
50+
steps:
51+
- name: Download all the dists
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
- name: Publish distribution 📦 to PyPI
57+
uses: pypa/gh-action-pypi-publish@release/v1
58+
59+
publish-to-testpypi:
60+
name: Publish Python 🐍 distribution 📦 to TestPyPI
61+
needs:
62+
- build
63+
runs-on: ubuntu-latest
3464

35-
- name: Build package
36-
run: python -m build
65+
environment:
66+
name: testpypi
67+
url: ${{ env.PYPI_TEST_URL }}
3768

38-
- name: Publish package to pypi
39-
uses: pypa/[email protected]
69+
permissions:
70+
id-token: write # IMPORTANT: mandatory for trusted publishing
71+
72+
steps:
73+
- name: Download all the dists
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: python-package-distributions
77+
path: dist/
78+
- name: Publish distribution 📦 to TestPyPI
79+
uses: pypa/gh-action-pypi-publish@release/v1
4080
with:
41-
print-hash: true
81+
repository-url: https://test.pypi.org/legacy/
82+
skip-existing: true

.github/workflows/test.yml

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Django CI
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
branches:
66
- master
77
push:
@@ -30,17 +30,17 @@ jobs:
3030
test:
3131
needs: [ 'flake8' ]
3232
runs-on: ubuntu-latest
33-
name: "Run tests ${{ matrix.python-version }}/${{ matrix.django-version }}/${{ matrix.fake-redis }}"
33+
name: "Run tests ${{ matrix.python-version }}/${{ matrix.django-version }}/${{ matrix.broker }}"
3434
strategy:
3535
max-parallel: 6
3636
matrix:
3737
python-version: [ '3.10', '3.11', '3.12' ]
3838
django-version: [ '5.0.7', '5.1.1' ]
39-
fake-redis: ['True', 'False']
39+
broker: [ 'redis', 'fakeredis', 'valkey' ]
4040
include:
4141
- python-version: '3.12'
4242
django-version: '5.1.1'
43-
fake-redis: 'False'
43+
broker: 'redis'
4444
coverage: yes
4545

4646
services:
@@ -54,6 +54,16 @@ jobs:
5454
--health-timeout 5s
5555
--health-retries 5
5656
57+
valkey:
58+
image: valkey/valkey:8.0
59+
ports:
60+
- 6380:6379
61+
options: >-
62+
--health-cmd "redis-cli ping"
63+
--health-interval 10s
64+
--health-timeout 5s
65+
--health-retries 5
66+
5767
outputs:
5868
version: ${{ steps.getVersion.outputs.VERSION }}
5969

@@ -91,7 +101,12 @@ jobs:
91101
if: ${{ matrix.coverage != 'yes' }}
92102
run: |
93103
cd testproject
94-
export FAKEREDIS=${{ matrix.fake-redis }}
104+
export FAKEREDIS=${{ matrix.broker == 'fakeredis' }}
105+
if [ ${{ matrix.broker == 'valkey' }} == true ]; then
106+
export BROKER_PORT=6380
107+
else
108+
export BROKER_PORT=6379
109+
fi
95110
poetry run python manage.py test scheduler
96111
97112
# Steps for coverage check
@@ -102,6 +117,7 @@ jobs:
102117
pythonVer: ${{ matrix.python-version }}
103118
djangoVer: ${{ matrix.django-version }}
104119
repoToken: ${{ secrets.GITHUB_TOKEN }}
120+
105121
- name: Create coverage badge
106122
if: ${{ matrix.coverage == 'yes' && github.event_name == 'push' }}
107123
uses: schneegans/[email protected]

docs/changelog.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## v2.1.0 🌈
4+
5+
### 🚀 Features
6+
7+
- Support for custom job-class for every worker, using `--job-class` option in `rqworker` command.
8+
- Support for integrating with sentry, using `--sentry-dsn`, `--sentry-debug`, and `--sentry-ca-certs` options in
9+
`rqworker` command.
10+
- Support for using ValKey as broker instead of redis.
11+
12+
### 🧰 Maintenance
13+
14+
- Refactor settings module.
15+
316
## v2.0.0 🌈
417

518
### Breaking Changes

docs/commands.md

+39-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,47 @@ If no queues are specified, will run on default queue only.
88
All queues must have the same redis settings on `SCHEDULER_QUEUES`.
99

1010
```shell
11-
python manage.py rqworker queue1 queue2 queue3
12-
11+
usage: manage.py rqworker [-h] [--pid PIDFILE] [--burst] [--name NAME] [--worker-ttl WORKER_TTL] [--max-jobs MAX_JOBS]
12+
[--fork-job-execution FORK_JOB_EXECUTION] [--job-class JOB_CLASS] [--sentry-dsn SENTRY_DSN] [--sentry-debug]
13+
[--sentry-ca-certs SENTRY_CA_CERTS] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH]
14+
[--traceback] [--no-color] [--force-color] [--skip-checks]
15+
[queues ...]
16+
17+
positional arguments:
18+
queues The queues to work on, separated by space, all queues should be using the same redis
19+
20+
options:
21+
-h, --help show this help message and exit
22+
--pid PIDFILE file to write the worker`s pid into
23+
--burst Run worker in burst mode
24+
--name NAME Name of the worker
25+
--worker-ttl WORKER_TTL
26+
Default worker timeout to be used
27+
--max-jobs MAX_JOBS Maximum number of jobs to execute before terminating worker
28+
--fork-job-execution FORK_JOB_EXECUTION
29+
Fork job execution to another process
30+
--job-class JOB_CLASS
31+
Jobs class to use
32+
--sentry-dsn SENTRY_DSN
33+
Sentry DSN to use
34+
--sentry-debug Enable Sentry debug mode
35+
--sentry-ca-certs SENTRY_CA_CERTS
36+
Path to CA certs file
37+
--version Show program's version number and exit.
38+
-v {0,1,2,3}, --verbosity {0,1,2,3}
39+
Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
40+
--settings SETTINGS The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the
41+
DJANGO_SETTINGS_MODULE environment variable will be used.
42+
--pythonpath PYTHONPATH
43+
A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
44+
--traceback Raise on CommandError exceptions.
45+
--no-color Don't colorize the command output.
46+
--force-color Force colorization of the command output.
47+
--skip-checks Skip system checks.
1348
```
1449
50+
51+
1552
## export
1653
1754
Export all scheduled tasks from django db to json/yaml format.

docs/configuration.md

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ SCHEDULER_CONFIG = {
1010
'DEFAULT_RESULT_TTL': 500,
1111
'DEFAULT_TIMEOUT': 300, # 5 minutes
1212
'SCHEDULER_INTERVAL': 10, # 10 seconds
13+
'BROKER': 'redis',
1314
}
1415
SCHEDULER_QUEUES = {
1516
'default': {
@@ -67,6 +68,12 @@ Enables checking stats using API token.
6768

6869
Default: no tokens allowed.
6970

71+
### SCHEDULER_CONFIG: `BROKER`
72+
73+
Broker driver to use for the scheduler. Can be `redis` or `valkey` or `fakeredis`.
74+
75+
Default: `redis`.
76+
7077
### `SCHEDULER_QUEUES`
7178

7279
You can configure the queues to work with.

docs/index.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,24 @@ sequenceDiagram
121121

122122
## Reporting issues or Features requests
123123

124-
Please report issues via [GitHub Issues](https://github.com/django-commons/django-tasks-scheduler/issues) .
124+
Please report issues via [GitHub Issues][6] .
125125

126126
---
127127

128128
## Acknowledgements
129129

130-
A lot of django-admin views and their tests were adopted from [django-rq](https://github.com/rq/django-rq).
130+
A lot of django-admin views and their tests were adopted from [django-rq][7].
131131

132132
[1]:https://github.com/django-commons/django-tasks-scheduler/actions/workflows/test.yml/badge.svg
133+
133134
[2]:https://github.com/django-commons/django-tasks-scheduler/actions/workflows/test.yml
135+
134136
[3]:https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/cunla/b756396efb895f0e34558c980f1ca0c7/raw/django-tasks-scheduler-4.json
137+
135138
[4]:https://img.shields.io/pypi/dm/django-tasks-scheduler
139+
136140
[5]:https://pypi.org/project/django-tasks-scheduler/
141+
142+
[6]:https://github.com/django-commons/django-tasks-scheduler/issues
143+
144+
[7]:https://github.com/rq/django-rq

docs/installation.md

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
'DEFAULT_RESULT_TTL': 500,
6767
'DEFAULT_TIMEOUT': 300, # 5 minutes
6868
'SCHEDULER_INTERVAL': 10, # 10 seconds
69+
'BROKER': 'redis', #
6970
}
7071
```
7172

0 commit comments

Comments
 (0)