aioq 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.
- aioq-0.1.0/.github/dependabot.yml +20 -0
- aioq-0.1.0/.github/workflows/ci.yml +59 -0
- aioq-0.1.0/.github/workflows/docs.yml +34 -0
- aioq-0.1.0/.github/workflows/release.yml +65 -0
- aioq-0.1.0/.gitignore +218 -0
- aioq-0.1.0/.pre-commit-config.yaml +30 -0
- aioq-0.1.0/LICENSE +21 -0
- aioq-0.1.0/PKG-INFO +71 -0
- aioq-0.1.0/README.md +36 -0
- aioq-0.1.0/docs/backends/custom.md +138 -0
- aioq-0.1.0/docs/backends/postgres.md +102 -0
- aioq-0.1.0/docs/backends/redis.md +73 -0
- aioq-0.1.0/docs/getting-started/installation.md +46 -0
- aioq-0.1.0/docs/getting-started/quickstart.md +94 -0
- aioq-0.1.0/docs/guide/cron.md +93 -0
- aioq-0.1.0/docs/guide/dashboard.md +89 -0
- aioq-0.1.0/docs/guide/enqueueing.md +88 -0
- aioq-0.1.0/docs/guide/tasks.md +113 -0
- aioq-0.1.0/docs/guide/workers.md +100 -0
- aioq-0.1.0/docs/index.md +77 -0
- aioq-0.1.0/docs/reference/aarq.md +75 -0
- aioq-0.1.0/docs/reference/broker.md +113 -0
- aioq-0.1.0/docs/reference/models.md +58 -0
- aioq-0.1.0/docs/reference/taskdef.md +58 -0
- aioq-0.1.0/docs/reference/worker.md +68 -0
- aioq-0.1.0/example.py +53 -0
- aioq-0.1.0/mkdocs.yml +70 -0
- aioq-0.1.0/pyproject.toml +84 -0
- aioq-0.1.0/src/aioq/__init__.py +4 -0
- aioq-0.1.0/src/aioq/app.py +86 -0
- aioq-0.1.0/src/aioq/backends/__init__.py +4 -0
- aioq-0.1.0/src/aioq/backends/base.py +76 -0
- aioq-0.1.0/src/aioq/backends/postgres.py +345 -0
- aioq-0.1.0/src/aioq/backends/redis.py +254 -0
- aioq-0.1.0/src/aioq/cli.py +70 -0
- aioq-0.1.0/src/aioq/cron.py +40 -0
- aioq-0.1.0/src/aioq/dashboard/__init__.py +3 -0
- aioq-0.1.0/src/aioq/dashboard/app.py +160 -0
- aioq-0.1.0/src/aioq/dashboard/templates/_job_rows.html +36 -0
- aioq-0.1.0/src/aioq/dashboard/templates/base.html +87 -0
- aioq-0.1.0/src/aioq/dashboard/templates/index.html +116 -0
- aioq-0.1.0/src/aioq/dashboard/templates/job_detail.html +163 -0
- aioq-0.1.0/src/aioq/dashboard/templates/jobs.html +60 -0
- aioq-0.1.0/src/aioq/models.py +44 -0
- aioq-0.1.0/src/aioq/task.py +66 -0
- aioq-0.1.0/src/aioq/worker.py +170 -0
- aioq-0.1.0/tests/__init__.py +0 -0
- aioq-0.1.0/tests/test_cancel.py +45 -0
- aioq-0.1.0/tests/test_cron.py +30 -0
- aioq-0.1.0/tests/test_models.py +16 -0
- aioq-0.1.0/tests/test_redis_broker.py +65 -0
- aioq-0.1.0/tests/test_retry.py +58 -0
- aioq-0.1.0/uv.lock +1526 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "pip"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
groups:
|
|
8
|
+
dev-dependencies:
|
|
9
|
+
patterns:
|
|
10
|
+
- "pytest*"
|
|
11
|
+
- "ruff"
|
|
12
|
+
- "mypy"
|
|
13
|
+
- "pre-commit"
|
|
14
|
+
- "fakeredis"
|
|
15
|
+
- "httpx"
|
|
16
|
+
|
|
17
|
+
- package-ecosystem: "github-actions"
|
|
18
|
+
directory: "/"
|
|
19
|
+
schedule:
|
|
20
|
+
interval: "weekly"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["**"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["**"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
name: Lint
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v6
|
|
15
|
+
|
|
16
|
+
- name: Install uv
|
|
17
|
+
uses: astral-sh/setup-uv@v7
|
|
18
|
+
with:
|
|
19
|
+
version: "latest"
|
|
20
|
+
|
|
21
|
+
- name: Run ruff lint
|
|
22
|
+
run: uvx ruff check .
|
|
23
|
+
|
|
24
|
+
- name: Run ruff format check
|
|
25
|
+
run: uvx ruff format --check .
|
|
26
|
+
|
|
27
|
+
test:
|
|
28
|
+
name: Test (Python ${{ matrix.python-version }})
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
strategy:
|
|
31
|
+
fail-fast: false
|
|
32
|
+
matrix:
|
|
33
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v6
|
|
37
|
+
|
|
38
|
+
- name: Install uv
|
|
39
|
+
uses: astral-sh/setup-uv@v7
|
|
40
|
+
with:
|
|
41
|
+
version: "latest"
|
|
42
|
+
|
|
43
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
44
|
+
uses: actions/setup-python@v6
|
|
45
|
+
with:
|
|
46
|
+
python-version: ${{ matrix.python-version }}
|
|
47
|
+
|
|
48
|
+
- name: Install dev dependencies
|
|
49
|
+
run: uv sync --extra dev
|
|
50
|
+
|
|
51
|
+
- name: Run tests
|
|
52
|
+
run: uv run pytest tests/ -v --cov=src/aioq --cov-report=xml
|
|
53
|
+
|
|
54
|
+
- name: Upload coverage
|
|
55
|
+
uses: codecov/codecov-action@v6
|
|
56
|
+
if: matrix.python-version == '3.11'
|
|
57
|
+
with:
|
|
58
|
+
files: coverage.xml
|
|
59
|
+
fail_ci_if_error: false
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Deploy docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
deploy:
|
|
13
|
+
name: Build and deploy docs
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
fetch-depth: 0 # full history for git-revision-date plugin
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
version: "latest"
|
|
24
|
+
|
|
25
|
+
- name: Set up Python
|
|
26
|
+
uses: actions/setup-python@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.11"
|
|
29
|
+
|
|
30
|
+
- name: Install docs dependencies
|
|
31
|
+
run: uv sync --extra docs
|
|
32
|
+
|
|
33
|
+
- name: Build and deploy to GitHub Pages
|
|
34
|
+
run: uv run mkdocs gh-deploy --force
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write # for PyPI trusted publishing
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
name: Build distribution
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v7
|
|
21
|
+
with:
|
|
22
|
+
version: "latest"
|
|
23
|
+
|
|
24
|
+
- name: Build package
|
|
25
|
+
run: uv build
|
|
26
|
+
|
|
27
|
+
- name: Upload dist artifacts
|
|
28
|
+
uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: dist
|
|
31
|
+
path: dist/
|
|
32
|
+
|
|
33
|
+
publish-pypi:
|
|
34
|
+
name: Publish to PyPI
|
|
35
|
+
needs: build
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
environment: pypi
|
|
38
|
+
steps:
|
|
39
|
+
- name: Download dist artifacts
|
|
40
|
+
uses: actions/download-artifact@v8
|
|
41
|
+
with:
|
|
42
|
+
name: dist
|
|
43
|
+
path: dist/
|
|
44
|
+
|
|
45
|
+
- name: Publish to PyPI
|
|
46
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
47
|
+
|
|
48
|
+
github-release:
|
|
49
|
+
name: Create GitHub Release
|
|
50
|
+
needs: build
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
steps:
|
|
53
|
+
- uses: actions/checkout@v6
|
|
54
|
+
|
|
55
|
+
- name: Download dist artifacts
|
|
56
|
+
uses: actions/download-artifact@v8
|
|
57
|
+
with:
|
|
58
|
+
name: dist
|
|
59
|
+
path: dist/
|
|
60
|
+
|
|
61
|
+
- name: Create GitHub Release
|
|
62
|
+
uses: softprops/action-gh-release@v2
|
|
63
|
+
with:
|
|
64
|
+
generate_release_notes: true
|
|
65
|
+
files: dist/*
|
aioq-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
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
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v5.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: check-yaml
|
|
8
|
+
- id: check-toml
|
|
9
|
+
- id: check-json
|
|
10
|
+
- id: check-added-large-files
|
|
11
|
+
- id: check-merge-conflict
|
|
12
|
+
- id: detect-private-key
|
|
13
|
+
- id: debug-statements
|
|
14
|
+
|
|
15
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
16
|
+
rev: v0.11.10
|
|
17
|
+
hooks:
|
|
18
|
+
- id: ruff
|
|
19
|
+
args: [--fix]
|
|
20
|
+
- id: ruff-format
|
|
21
|
+
|
|
22
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
23
|
+
rev: v1.15.0
|
|
24
|
+
hooks:
|
|
25
|
+
- id: mypy
|
|
26
|
+
args: [--ignore-missing-imports, --explicit-package-bases]
|
|
27
|
+
additional_dependencies:
|
|
28
|
+
- pydantic>=2.0
|
|
29
|
+
- types-redis
|
|
30
|
+
- types-croniter
|
aioq-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kusama yoshiki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
aioq-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aioq
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async job queue with multiple backend support and built-in dashboard
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: anyio>=4.0
|
|
8
|
+
Requires-Dist: click>=8.1
|
|
9
|
+
Requires-Dist: fastapi>=0.111
|
|
10
|
+
Requires-Dist: jinja2>=3.1
|
|
11
|
+
Requires-Dist: pydantic>=2.0
|
|
12
|
+
Requires-Dist: redis>=5.0
|
|
13
|
+
Requires-Dist: uvicorn[standard]>=0.30
|
|
14
|
+
Provides-Extra: all
|
|
15
|
+
Requires-Dist: asyncpg>=0.29; extra == 'all'
|
|
16
|
+
Requires-Dist: croniter>=2.0; extra == 'all'
|
|
17
|
+
Provides-Extra: cron
|
|
18
|
+
Requires-Dist: croniter>=2.0; extra == 'cron'
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: asyncpg>=0.29; extra == 'dev'
|
|
21
|
+
Requires-Dist: croniter>=2.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: fakeredis>=2.23; extra == 'dev'
|
|
23
|
+
Requires-Dist: httpx>=0.27; extra == 'dev'
|
|
24
|
+
Requires-Dist: pre-commit>=3.7; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
28
|
+
Provides-Extra: docs
|
|
29
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
30
|
+
Requires-Dist: mkdocs>=1.6; extra == 'docs'
|
|
31
|
+
Requires-Dist: pymdown-extensions>=10.0; extra == 'docs'
|
|
32
|
+
Provides-Extra: postgres
|
|
33
|
+
Requires-Dist: asyncpg>=0.29; extra == 'postgres'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# aioq
|
|
37
|
+
|
|
38
|
+
Async job queue for Python with Redis/PostgreSQL backends and a built-in real-time dashboard.
|
|
39
|
+
|
|
40
|
+
**[Documentation](https://ykus4.github.io/aioq/)** · [PyPI](https://pypi.org/project/aioq/)
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install aioq # Redis
|
|
46
|
+
pip install "aioq[all]" # Redis + PostgreSQL + cron
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick start
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from aioq import Aarq
|
|
53
|
+
from aioq.backends import RedisBroker
|
|
54
|
+
|
|
55
|
+
app = Aarq(broker=RedisBroker())
|
|
56
|
+
|
|
57
|
+
@app.task(queue="default", retries=3)
|
|
58
|
+
async def send_email(ctx, to: str, subject: str) -> dict:
|
|
59
|
+
...
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
aioq worker tasks:app # run a worker
|
|
64
|
+
aioq dashboard tasks:app # open the dashboard at :8080
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
See the **[docs](https://ykus4.github.io/aioq/)** for full usage, backend configuration, and API reference.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|
aioq-0.1.0/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# aioq
|
|
2
|
+
|
|
3
|
+
Async job queue for Python with Redis/PostgreSQL backends and a built-in real-time dashboard.
|
|
4
|
+
|
|
5
|
+
**[Documentation](https://ykus4.github.io/aioq/)** · [PyPI](https://pypi.org/project/aioq/)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install aioq # Redis
|
|
11
|
+
pip install "aioq[all]" # Redis + PostgreSQL + cron
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from aioq import Aarq
|
|
18
|
+
from aioq.backends import RedisBroker
|
|
19
|
+
|
|
20
|
+
app = Aarq(broker=RedisBroker())
|
|
21
|
+
|
|
22
|
+
@app.task(queue="default", retries=3)
|
|
23
|
+
async def send_email(ctx, to: str, subject: str) -> dict:
|
|
24
|
+
...
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
aioq worker tasks:app # run a worker
|
|
29
|
+
aioq dashboard tasks:app # open the dashboard at :8080
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
See the **[docs](https://ykus4.github.io/aioq/)** for full usage, backend configuration, and API reference.
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Custom Backend
|
|
2
|
+
|
|
3
|
+
You can add support for any storage system by subclassing `BaseBroker` and implementing all abstract methods.
|
|
4
|
+
|
|
5
|
+
## Implementation template
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from aioq.backends.base import BaseBroker
|
|
9
|
+
from aioq.models import Job, JobStatus
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MyBroker(BaseBroker):
|
|
13
|
+
|
|
14
|
+
# ------------------------------------------------------------------
|
|
15
|
+
# Lifecycle
|
|
16
|
+
# ------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
async def connect(self) -> None:
|
|
19
|
+
"""Open connections / pools."""
|
|
20
|
+
...
|
|
21
|
+
|
|
22
|
+
async def disconnect(self) -> None:
|
|
23
|
+
"""Close connections / pools."""
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
# ------------------------------------------------------------------
|
|
27
|
+
# Job lifecycle
|
|
28
|
+
# ------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
async def enqueue(self, job: Job) -> None:
|
|
31
|
+
"""Persist and publish a job."""
|
|
32
|
+
...
|
|
33
|
+
|
|
34
|
+
async def dequeue(self, queues: list[str], timeout: float = 2.0) -> Job | None:
|
|
35
|
+
"""
|
|
36
|
+
Block until a job is available on any of `queues`, or until
|
|
37
|
+
`timeout` seconds elapse. Return None on timeout.
|
|
38
|
+
|
|
39
|
+
Must be safe for concurrent workers (only one worker receives each job).
|
|
40
|
+
"""
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
async def ack(self, job: Job) -> None:
|
|
44
|
+
"""Acknowledge successful completion."""
|
|
45
|
+
...
|
|
46
|
+
|
|
47
|
+
async def nack(self, job: Job, requeue: bool = False) -> None:
|
|
48
|
+
"""Negative-acknowledge a job. Requeue if `requeue=True`."""
|
|
49
|
+
...
|
|
50
|
+
|
|
51
|
+
async def update_job(self, job: Job) -> None:
|
|
52
|
+
"""Persist updated job state (status, result, error, etc.)."""
|
|
53
|
+
...
|
|
54
|
+
|
|
55
|
+
async def get_job(self, job_id: str) -> Job | None:
|
|
56
|
+
"""Fetch a single job by ID."""
|
|
57
|
+
...
|
|
58
|
+
|
|
59
|
+
async def list_jobs(
|
|
60
|
+
self,
|
|
61
|
+
queue: str | None = None,
|
|
62
|
+
status: JobStatus | None = None,
|
|
63
|
+
limit: int = 100,
|
|
64
|
+
offset: int = 0,
|
|
65
|
+
) -> list[Job]:
|
|
66
|
+
"""Return jobs filtered by queue/status, ordered by enqueued_at desc."""
|
|
67
|
+
...
|
|
68
|
+
|
|
69
|
+
async def queue_stats(self) -> dict[str, dict[str, int]]:
|
|
70
|
+
"""
|
|
71
|
+
Return per-queue status counts.
|
|
72
|
+
Example: {"default": {"pending": 3, "running": 1, "completed": 42}}
|
|
73
|
+
"""
|
|
74
|
+
...
|
|
75
|
+
|
|
76
|
+
async def cancel_job(self, job_id: str) -> bool:
|
|
77
|
+
"""
|
|
78
|
+
Set a pending/retrying job to cancelled.
|
|
79
|
+
Return True if cancelled, False if the job was in a non-cancellable state.
|
|
80
|
+
"""
|
|
81
|
+
...
|
|
82
|
+
|
|
83
|
+
async def retry_job(self, job_id: str) -> bool:
|
|
84
|
+
"""
|
|
85
|
+
Reset a failed/cancelled job to pending and re-enqueue it.
|
|
86
|
+
Return True if retried, False if the job was in a non-retryable state.
|
|
87
|
+
"""
|
|
88
|
+
...
|
|
89
|
+
|
|
90
|
+
# ------------------------------------------------------------------
|
|
91
|
+
# Workers
|
|
92
|
+
# ------------------------------------------------------------------
|
|
93
|
+
|
|
94
|
+
async def register_worker(self, worker_id: str, queues: list[str]) -> None:
|
|
95
|
+
"""Register a worker on startup."""
|
|
96
|
+
...
|
|
97
|
+
|
|
98
|
+
async def heartbeat_worker(self, worker_id: str) -> None:
|
|
99
|
+
"""Update the worker's last-seen timestamp."""
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
async def deregister_worker(self, worker_id: str) -> None:
|
|
103
|
+
"""Remove the worker on shutdown."""
|
|
104
|
+
...
|
|
105
|
+
|
|
106
|
+
async def list_workers(self) -> list[dict]:
|
|
107
|
+
"""
|
|
108
|
+
Return a list of worker dicts. Each dict must include at minimum:
|
|
109
|
+
worker_id, queues, registered_at, last_heartbeat, alive
|
|
110
|
+
"""
|
|
111
|
+
...
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Registration
|
|
115
|
+
|
|
116
|
+
Pass your broker to `Aarq` like any other:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from aioq import Aarq
|
|
120
|
+
|
|
121
|
+
broker = MyBroker(...)
|
|
122
|
+
app = Aarq(broker=broker)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Context manager support
|
|
126
|
+
|
|
127
|
+
`BaseBroker` already implements `__aenter__` / `__aexit__` which call `connect()` and `disconnect()`. You get this for free:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
async with MyBroker(...) as broker:
|
|
131
|
+
await broker.enqueue(job)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Tips
|
|
135
|
+
|
|
136
|
+
- **Dequeue atomicity**: the most important invariant is that `dequeue()` returns a job to at most one worker. Use `SELECT ... FOR UPDATE SKIP LOCKED` (SQL), `BRPOP` (Redis), or an equivalent mechanism.
|
|
137
|
+
- **Timeout**: `dequeue()` should block for at most `timeout` seconds and return `None` if nothing arrives. This lets the worker check `_running` regularly for graceful shutdown.
|
|
138
|
+
- **Worker liveness**: store `last_heartbeat` and expose an `alive` boolean in `list_workers()` (e.g. `alive = last_heartbeat > now - 30s`). The dashboard uses this.
|