z4j-taskiqscheduler 1.0.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.
- z4j_taskiqscheduler-1.0.0/.github/CODEOWNERS +2 -0
- z4j_taskiqscheduler-1.0.0/.github/ISSUE_TEMPLATE/bug_report.yml +74 -0
- z4j_taskiqscheduler-1.0.0/.github/ISSUE_TEMPLATE/config.yml +8 -0
- z4j_taskiqscheduler-1.0.0/.github/ISSUE_TEMPLATE/feature_request.yml +33 -0
- z4j_taskiqscheduler-1.0.0/.github/dependabot.yml +35 -0
- z4j_taskiqscheduler-1.0.0/.github/workflows/ci.yml +109 -0
- z4j_taskiqscheduler-1.0.0/.github/workflows/release.yml +65 -0
- z4j_taskiqscheduler-1.0.0/.gitignore +22 -0
- z4j_taskiqscheduler-1.0.0/CHANGELOG.md +32 -0
- z4j_taskiqscheduler-1.0.0/LICENSE +201 -0
- z4j_taskiqscheduler-1.0.0/PKG-INFO +73 -0
- z4j_taskiqscheduler-1.0.0/README.md +47 -0
- z4j_taskiqscheduler-1.0.0/SECURITY.md +37 -0
- z4j_taskiqscheduler-1.0.0/pyproject.toml +37 -0
- z4j_taskiqscheduler-1.0.0/src/z4j_taskiqscheduler/__init__.py +9 -0
- z4j_taskiqscheduler-1.0.0/src/z4j_taskiqscheduler/capabilities.py +9 -0
- z4j_taskiqscheduler-1.0.0/src/z4j_taskiqscheduler/py.typed +0 -0
- z4j_taskiqscheduler-1.0.0/src/z4j_taskiqscheduler/scheduler.py +174 -0
- z4j_taskiqscheduler-1.0.0/tests/__init__.py +0 -0
- z4j_taskiqscheduler-1.0.0/tests/unit/__init__.py +0 -0
- z4j_taskiqscheduler-1.0.0/tests/unit/test_scheduler.py +82 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: Report a problem with z4j-taskiqscheduler
|
|
3
|
+
title: "[bug] "
|
|
4
|
+
labels: ["bug", "triage"]
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thanks for reporting a bug in `z4j-taskiqscheduler`.
|
|
10
|
+
|
|
11
|
+
**Security bugs do NOT belong here.** If you believe you've
|
|
12
|
+
found a security issue, please email `security@z4j.com` —
|
|
13
|
+
see [SECURITY.md](../blob/main/SECURITY.md).
|
|
14
|
+
|
|
15
|
+
- type: input
|
|
16
|
+
id: package-version
|
|
17
|
+
attributes:
|
|
18
|
+
label: z4j-taskiqscheduler version
|
|
19
|
+
description: Output of `pip show z4j-taskiqscheduler | grep -E 'Name|Version'`
|
|
20
|
+
placeholder: z4j-taskiqscheduler 1.0.0
|
|
21
|
+
validations:
|
|
22
|
+
required: true
|
|
23
|
+
|
|
24
|
+
- type: input
|
|
25
|
+
id: python-version
|
|
26
|
+
attributes:
|
|
27
|
+
label: Python version
|
|
28
|
+
placeholder: 3.14.4
|
|
29
|
+
validations:
|
|
30
|
+
required: true
|
|
31
|
+
|
|
32
|
+
- type: dropdown
|
|
33
|
+
id: module
|
|
34
|
+
attributes:
|
|
35
|
+
label: Affected module
|
|
36
|
+
description: (Customize this dropdown's options per package.)
|
|
37
|
+
options:
|
|
38
|
+
- Unsure / multiple
|
|
39
|
+
validations:
|
|
40
|
+
required: false
|
|
41
|
+
|
|
42
|
+
- type: textarea
|
|
43
|
+
id: repro
|
|
44
|
+
attributes:
|
|
45
|
+
label: Minimal reproduction
|
|
46
|
+
description: A standalone script is ideal.
|
|
47
|
+
validations:
|
|
48
|
+
required: true
|
|
49
|
+
|
|
50
|
+
- type: textarea
|
|
51
|
+
id: expected
|
|
52
|
+
attributes:
|
|
53
|
+
label: Expected behavior
|
|
54
|
+
validations:
|
|
55
|
+
required: true
|
|
56
|
+
|
|
57
|
+
- type: textarea
|
|
58
|
+
id: actual
|
|
59
|
+
attributes:
|
|
60
|
+
label: Actual behavior
|
|
61
|
+
description: Include the full traceback if applicable. Please redact secrets.
|
|
62
|
+
render: shell
|
|
63
|
+
validations:
|
|
64
|
+
required: true
|
|
65
|
+
|
|
66
|
+
- type: checkboxes
|
|
67
|
+
id: terms
|
|
68
|
+
attributes:
|
|
69
|
+
label: Confirmation
|
|
70
|
+
options:
|
|
71
|
+
- label: I searched existing issues and this is not a duplicate
|
|
72
|
+
required: true
|
|
73
|
+
- label: This is NOT a security issue (those go to security@z4j.com)
|
|
74
|
+
required: true
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: Security vulnerability
|
|
4
|
+
url: mailto:security@z4j.com
|
|
5
|
+
about: Report a security issue privately
|
|
6
|
+
- name: Question or discussion
|
|
7
|
+
url: https://github.com/z4jdev/z4j/discussions
|
|
8
|
+
about: General questions about z4j go to the project-wide Discussions
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Feature request
|
|
2
|
+
description: Suggest a capability for z4j-taskiqscheduler
|
|
3
|
+
title: "[feature] "
|
|
4
|
+
labels: ["enhancement", "triage"]
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thanks for suggesting a feature for `z4j-taskiqscheduler`. Please describe
|
|
10
|
+
the problem you're trying to solve, not just the solution you
|
|
11
|
+
have in mind.
|
|
12
|
+
|
|
13
|
+
- type: textarea
|
|
14
|
+
id: problem
|
|
15
|
+
attributes:
|
|
16
|
+
label: Problem
|
|
17
|
+
description: What are you trying to do that z4j-taskiqscheduler does not currently support?
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
|
|
21
|
+
- type: textarea
|
|
22
|
+
id: proposed
|
|
23
|
+
attributes:
|
|
24
|
+
label: Proposed solution
|
|
25
|
+
validations:
|
|
26
|
+
required: false
|
|
27
|
+
|
|
28
|
+
- type: textarea
|
|
29
|
+
id: alternatives
|
|
30
|
+
attributes:
|
|
31
|
+
label: Alternatives considered
|
|
32
|
+
validations:
|
|
33
|
+
required: false
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: uv
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: weekly
|
|
7
|
+
day: monday
|
|
8
|
+
time: "04:00"
|
|
9
|
+
timezone: UTC
|
|
10
|
+
open-pull-requests-limit: 5
|
|
11
|
+
labels:
|
|
12
|
+
- dependencies
|
|
13
|
+
- python
|
|
14
|
+
commit-message:
|
|
15
|
+
prefix: chore
|
|
16
|
+
include: scope
|
|
17
|
+
groups:
|
|
18
|
+
minor-and-patch:
|
|
19
|
+
update-types:
|
|
20
|
+
- minor
|
|
21
|
+
- patch
|
|
22
|
+
|
|
23
|
+
- package-ecosystem: github-actions
|
|
24
|
+
directory: /
|
|
25
|
+
schedule:
|
|
26
|
+
interval: weekly
|
|
27
|
+
day: monday
|
|
28
|
+
time: "04:00"
|
|
29
|
+
timezone: UTC
|
|
30
|
+
open-pull-requests-limit: 3
|
|
31
|
+
labels:
|
|
32
|
+
- dependencies
|
|
33
|
+
- ci
|
|
34
|
+
commit-message:
|
|
35
|
+
prefix: ci
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ci-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
env:
|
|
17
|
+
UV_VERSION: "0.5.11"
|
|
18
|
+
FORCE_COLOR: "1"
|
|
19
|
+
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
lint:
|
|
23
|
+
name: Lint and format
|
|
24
|
+
runs-on: ubuntu-24.04
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
|
|
28
|
+
- name: Set up Python
|
|
29
|
+
uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: "3.14"
|
|
32
|
+
|
|
33
|
+
- name: Install uv
|
|
34
|
+
uses: astral-sh/setup-uv@v4
|
|
35
|
+
with:
|
|
36
|
+
version: ${{ env.UV_VERSION }}
|
|
37
|
+
enable-cache: true
|
|
38
|
+
|
|
39
|
+
- name: Sync dependencies
|
|
40
|
+
run: uv sync --all-extras --dev
|
|
41
|
+
|
|
42
|
+
- name: Ruff check
|
|
43
|
+
run: uv run ruff check .
|
|
44
|
+
|
|
45
|
+
- name: Ruff format check
|
|
46
|
+
run: uv run ruff format --check .
|
|
47
|
+
|
|
48
|
+
- name: Mypy
|
|
49
|
+
run: uv run mypy src
|
|
50
|
+
|
|
51
|
+
test:
|
|
52
|
+
name: Tests (Python ${{ matrix.python-version }})
|
|
53
|
+
runs-on: ubuntu-24.04
|
|
54
|
+
needs: [lint]
|
|
55
|
+
strategy:
|
|
56
|
+
fail-fast: false
|
|
57
|
+
matrix:
|
|
58
|
+
python-version: ["3.13", "3.14"]
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/checkout@v4
|
|
61
|
+
|
|
62
|
+
- name: Set up Python
|
|
63
|
+
uses: actions/setup-python@v5
|
|
64
|
+
with:
|
|
65
|
+
python-version: ${{ matrix.python-version }}
|
|
66
|
+
|
|
67
|
+
- name: Install uv
|
|
68
|
+
uses: astral-sh/setup-uv@v4
|
|
69
|
+
with:
|
|
70
|
+
version: ${{ env.UV_VERSION }}
|
|
71
|
+
enable-cache: true
|
|
72
|
+
|
|
73
|
+
- name: Sync dependencies
|
|
74
|
+
run: uv sync --all-extras --dev
|
|
75
|
+
|
|
76
|
+
- name: Run tests
|
|
77
|
+
run: uv run pytest -xvs tests/
|
|
78
|
+
|
|
79
|
+
build:
|
|
80
|
+
name: Build wheel + sdist
|
|
81
|
+
runs-on: ubuntu-24.04
|
|
82
|
+
needs: [test]
|
|
83
|
+
steps:
|
|
84
|
+
- uses: actions/checkout@v4
|
|
85
|
+
|
|
86
|
+
- name: Set up Python
|
|
87
|
+
uses: actions/setup-python@v5
|
|
88
|
+
with:
|
|
89
|
+
python-version: "3.14"
|
|
90
|
+
|
|
91
|
+
- name: Install uv
|
|
92
|
+
uses: astral-sh/setup-uv@v4
|
|
93
|
+
with:
|
|
94
|
+
version: ${{ env.UV_VERSION }}
|
|
95
|
+
|
|
96
|
+
- name: Build
|
|
97
|
+
run: uv build
|
|
98
|
+
|
|
99
|
+
- name: Validate metadata
|
|
100
|
+
run: |
|
|
101
|
+
uv tool install twine
|
|
102
|
+
uv tool run twine check dist/*
|
|
103
|
+
|
|
104
|
+
- name: Upload artefacts
|
|
105
|
+
uses: actions/upload-artifact@v4
|
|
106
|
+
with:
|
|
107
|
+
name: dist
|
|
108
|
+
path: dist/
|
|
109
|
+
retention-days: 7
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Manual-publish phase: this workflow builds the package and attaches
|
|
4
|
+
# the wheel + sdist to a GitHub Release. It does NOT upload to PyPI.
|
|
5
|
+
# PyPI uploads are hand-picked from a local staging folder via twine,
|
|
6
|
+
# under the maintainer's direct control. See docs/RELEASE.md.
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
tags:
|
|
11
|
+
- "v*.*.*"
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: write
|
|
15
|
+
id-token: read
|
|
16
|
+
|
|
17
|
+
env:
|
|
18
|
+
UV_VERSION: "0.5.11"
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
build-and-release:
|
|
22
|
+
name: Build and attach to GitHub Release
|
|
23
|
+
runs-on: ubuntu-24.04
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- name: Verify tag matches pyproject version
|
|
28
|
+
run: |
|
|
29
|
+
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
|
30
|
+
PKG_VERSION=$(grep -E '^version = ' pyproject.toml | head -1 | sed -E 's/version = "(.*)"/\1/')
|
|
31
|
+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
|
|
32
|
+
echo "::error::Tag $GITHUB_REF_NAME does not match pyproject version $PKG_VERSION"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
- name: Set up Python
|
|
37
|
+
uses: actions/setup-python@v5
|
|
38
|
+
with:
|
|
39
|
+
python-version: "3.14"
|
|
40
|
+
|
|
41
|
+
- name: Install uv
|
|
42
|
+
uses: astral-sh/setup-uv@v4
|
|
43
|
+
with:
|
|
44
|
+
version: ${{ env.UV_VERSION }}
|
|
45
|
+
|
|
46
|
+
- name: Sync dependencies
|
|
47
|
+
run: uv sync --all-extras --dev
|
|
48
|
+
|
|
49
|
+
- name: Run tests
|
|
50
|
+
run: uv run pytest -xvs tests/
|
|
51
|
+
|
|
52
|
+
- name: Build wheel + sdist
|
|
53
|
+
run: uv build
|
|
54
|
+
|
|
55
|
+
- name: Validate metadata
|
|
56
|
+
run: |
|
|
57
|
+
uv tool install twine
|
|
58
|
+
uv tool run twine check dist/*
|
|
59
|
+
|
|
60
|
+
- name: Create GitHub Release with artefacts
|
|
61
|
+
uses: softprops/action-gh-release@v2
|
|
62
|
+
with:
|
|
63
|
+
files: dist/*
|
|
64
|
+
generate_release_notes: true
|
|
65
|
+
fail_on_unmatched_files: true
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Build output
|
|
2
|
+
dist/
|
|
3
|
+
build/
|
|
4
|
+
*.egg-info/
|
|
5
|
+
|
|
6
|
+
# Python caches
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.pyc
|
|
9
|
+
.pytest_cache/
|
|
10
|
+
.mypy_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.hypothesis/
|
|
13
|
+
|
|
14
|
+
# Virtualenvs
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
|
|
18
|
+
# IDE / editor
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
*.swp
|
|
22
|
+
.DS_Store
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `z4j-taskiqscheduler` are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.0.0] - 2026-04
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
<!--
|
|
15
|
+
TODO: describe what ships in this first public release. One bullet per
|
|
16
|
+
capability. Examples:
|
|
17
|
+
- First public release.
|
|
18
|
+
- <Headline feature>
|
|
19
|
+
- <Second feature>
|
|
20
|
+
- N unit tests.
|
|
21
|
+
-->
|
|
22
|
+
|
|
23
|
+
- First public release.
|
|
24
|
+
|
|
25
|
+
## Links
|
|
26
|
+
|
|
27
|
+
- Repository: <https://github.com/z4jdev/z4j-taskiqscheduler>
|
|
28
|
+
- Issues: <https://github.com/z4jdev/z4j-taskiqscheduler/issues>
|
|
29
|
+
- PyPI: <https://pypi.org/project/z4j-taskiqscheduler/>
|
|
30
|
+
|
|
31
|
+
[Unreleased]: https://github.com/z4jdev/z4j-taskiqscheduler/compare/v1.0.0...HEAD
|
|
32
|
+
[1.0.0]: https://github.com/z4jdev/z4j-taskiqscheduler/releases/tag/v1.0.0
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 z4j contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: z4j-taskiqscheduler
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: z4j scheduler adapter for taskiq schedule sources (Apache 2.0)
|
|
5
|
+
Project-URL: Changelog, https://github.com/z4jdev/z4j-taskiqscheduler/blob/main/CHANGELOG.md
|
|
6
|
+
Project-URL: Documentation, https://z4j.dev
|
|
7
|
+
Project-URL: Homepage, https://z4j.com
|
|
8
|
+
Project-URL: Issues, https://github.com/z4jdev/z4j-taskiqscheduler/issues
|
|
9
|
+
Project-URL: Source, https://github.com/z4jdev/z4j-taskiqscheduler
|
|
10
|
+
Author: z4j contributors
|
|
11
|
+
License: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: cron,scheduler,taskiq,z4j
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.13
|
|
23
|
+
Requires-Dist: taskiq<1,>=0.11
|
|
24
|
+
Requires-Dist: z4j-core<2.0,>=1.0
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# z4j-taskiqscheduler
|
|
28
|
+
|
|
29
|
+
[](https://pypi.org/project/z4j-taskiqscheduler/)
|
|
30
|
+
[](https://pypi.org/project/z4j-taskiqscheduler/)
|
|
31
|
+
[](https://github.com/z4jdev/z4j-taskiqscheduler/blob/main/LICENSE)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
z4j scheduler adapter for taskiq's schedule sources
|
|
35
|
+
(`LabelScheduleSource`, custom backends).
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from taskiq.schedule_sources import LabelScheduleSource
|
|
39
|
+
from z4j_taskiq import TaskiqEngineAdapter
|
|
40
|
+
from z4j_taskiqscheduler import TaskiqSchedulerAdapter
|
|
41
|
+
|
|
42
|
+
source = LabelScheduleSource(broker)
|
|
43
|
+
|
|
44
|
+
# In your z4j-bare bootstrap:
|
|
45
|
+
from z4j_bare import install_agent
|
|
46
|
+
install_agent(
|
|
47
|
+
engines=[TaskiqEngineAdapter(broker=broker)],
|
|
48
|
+
schedulers=[TaskiqSchedulerAdapter(source=source)],
|
|
49
|
+
)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Capabilities
|
|
53
|
+
|
|
54
|
+
- ✅ List + read schedules from any taskiq schedule source
|
|
55
|
+
- ✅ Delete (when source supports it)
|
|
56
|
+
- ❌ Create / update — taskiq sources don't expose a generic
|
|
57
|
+
add-from-spec API; LabelScheduleSource is read-only at runtime
|
|
58
|
+
by design.
|
|
59
|
+
|
|
60
|
+
Apache 2.0.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
Apache 2.0 — see [LICENSE](LICENSE). This package is deliberately permissively licensed so that proprietary Django / Flask / FastAPI applications can import it without any license concerns.
|
|
65
|
+
|
|
66
|
+
## Links
|
|
67
|
+
|
|
68
|
+
- Homepage: <https://z4j.com>
|
|
69
|
+
- Documentation: <https://z4j.dev>
|
|
70
|
+
- Source: <https://github.com/z4jdev/z4j-taskiqscheduler>
|
|
71
|
+
- Issues: <https://github.com/z4jdev/z4j-taskiqscheduler/issues>
|
|
72
|
+
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
73
|
+
- Security: `security@z4j.com` (see [SECURITY.md](SECURITY.md))
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# z4j-taskiqscheduler
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/z4j-taskiqscheduler/)
|
|
4
|
+
[](https://pypi.org/project/z4j-taskiqscheduler/)
|
|
5
|
+
[](https://github.com/z4jdev/z4j-taskiqscheduler/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
z4j scheduler adapter for taskiq's schedule sources
|
|
9
|
+
(`LabelScheduleSource`, custom backends).
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from taskiq.schedule_sources import LabelScheduleSource
|
|
13
|
+
from z4j_taskiq import TaskiqEngineAdapter
|
|
14
|
+
from z4j_taskiqscheduler import TaskiqSchedulerAdapter
|
|
15
|
+
|
|
16
|
+
source = LabelScheduleSource(broker)
|
|
17
|
+
|
|
18
|
+
# In your z4j-bare bootstrap:
|
|
19
|
+
from z4j_bare import install_agent
|
|
20
|
+
install_agent(
|
|
21
|
+
engines=[TaskiqEngineAdapter(broker=broker)],
|
|
22
|
+
schedulers=[TaskiqSchedulerAdapter(source=source)],
|
|
23
|
+
)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Capabilities
|
|
27
|
+
|
|
28
|
+
- ✅ List + read schedules from any taskiq schedule source
|
|
29
|
+
- ✅ Delete (when source supports it)
|
|
30
|
+
- ❌ Create / update — taskiq sources don't expose a generic
|
|
31
|
+
add-from-spec API; LabelScheduleSource is read-only at runtime
|
|
32
|
+
by design.
|
|
33
|
+
|
|
34
|
+
Apache 2.0.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
Apache 2.0 — see [LICENSE](LICENSE). This package is deliberately permissively licensed so that proprietary Django / Flask / FastAPI applications can import it without any license concerns.
|
|
39
|
+
|
|
40
|
+
## Links
|
|
41
|
+
|
|
42
|
+
- Homepage: <https://z4j.com>
|
|
43
|
+
- Documentation: <https://z4j.dev>
|
|
44
|
+
- Source: <https://github.com/z4jdev/z4j-taskiqscheduler>
|
|
45
|
+
- Issues: <https://github.com/z4jdev/z4j-taskiqscheduler/issues>
|
|
46
|
+
- Changelog: [CHANGELOG.md](CHANGELOG.md)
|
|
47
|
+
- Security: `security@z4j.com` (see [SECURITY.md](SECURITY.md))
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
If you believe you have found a security vulnerability in `z4j-taskiqscheduler`,
|
|
6
|
+
**do not open a public GitHub issue**. Email `security@z4j.com` instead.
|
|
7
|
+
|
|
8
|
+
We follow the [disclose.io](https://disclose.io) baseline:
|
|
9
|
+
|
|
10
|
+
- Initial acknowledgement within **72 hours**.
|
|
11
|
+
- Coordinated disclosure timeline agreed before public release.
|
|
12
|
+
- Credit in the release notes (unless you prefer to remain anonymous).
|
|
13
|
+
|
|
14
|
+
PGP key and the full disclosure policy live in the
|
|
15
|
+
[z4j project security policy](https://github.com/z4jdev/z4j/blob/main/SECURITY.md).
|
|
16
|
+
|
|
17
|
+
## Supported versions
|
|
18
|
+
|
|
19
|
+
Only the latest minor release receives security fixes. See
|
|
20
|
+
[CHANGELOG.md](CHANGELOG.md) for the current version.
|
|
21
|
+
|
|
22
|
+
## Security-critical surface
|
|
23
|
+
|
|
24
|
+
<!--
|
|
25
|
+
TODO: replace this block with the package-specific security-critical
|
|
26
|
+
surface. Example (from z4j-core):
|
|
27
|
+
|
|
28
|
+
- **Module X** (`z4j_taskiqscheduler.x`) — describe why a bug here would
|
|
29
|
+
have cross-cutting impact.
|
|
30
|
+
- **Module Y** — same.
|
|
31
|
+
|
|
32
|
+
If this package has no security-critical surface beyond the generic
|
|
33
|
+
ones covered by z4j-core, you can delete this section entirely.
|
|
34
|
+
-->
|
|
35
|
+
|
|
36
|
+
This package has no package-specific security-critical surface beyond
|
|
37
|
+
the generic ones owned by `z4j-core` (transport / redaction / policy).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "z4j-taskiqscheduler"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "z4j scheduler adapter for taskiq schedule sources (Apache 2.0)"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
license = { text = "Apache-2.0" }
|
|
8
|
+
authors = [{ name = "z4j contributors" }]
|
|
9
|
+
keywords = ["z4j", "taskiq", "scheduler", "cron"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 5 - Production/Stable",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"License :: OSI Approved :: Apache Software License",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
"Programming Language :: Python :: 3.14",
|
|
17
|
+
"Topic :: System :: Distributed Computing",
|
|
18
|
+
"Typing :: Typed",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"z4j-core>=1.0,<2.0",
|
|
22
|
+
"taskiq>=0.11,<1",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Changelog = "https://github.com/z4jdev/z4j-taskiqscheduler/blob/main/CHANGELOG.md"
|
|
27
|
+
Documentation = "https://z4j.dev"
|
|
28
|
+
Homepage = "https://z4j.com"
|
|
29
|
+
Issues = "https://github.com/z4jdev/z4j-taskiqscheduler/issues"
|
|
30
|
+
Source = "https://github.com/z4jdev/z4j-taskiqscheduler"
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
requires = ["hatchling"]
|
|
34
|
+
build-backend = "hatchling.build"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel]
|
|
37
|
+
packages = ["src/z4j_taskiqscheduler"]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""z4j-taskiqscheduler — scheduler adapter for taskiq schedule sources."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from z4j_taskiqscheduler.scheduler import TaskiqSchedulerAdapter
|
|
6
|
+
|
|
7
|
+
__version__ = "1.0.0"
|
|
8
|
+
|
|
9
|
+
__all__ = ["TaskiqSchedulerAdapter", "__version__"]
|
|
File without changes
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""The :class:`TaskiqSchedulerAdapter` — wraps any taskiq
|
|
2
|
+
``ScheduleSource`` (LabelScheduleSource and friends).
|
|
3
|
+
|
|
4
|
+
LabelScheduleSource walks the broker's task registry and reads
|
|
5
|
+
schedule metadata from each task's ``schedule=[]`` decorator
|
|
6
|
+
argument. It supports list / read / delete; create + update are
|
|
7
|
+
not part of its contract (schedules are decorator-defined,
|
|
8
|
+
source-controlled).
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import logging
|
|
14
|
+
from datetime import UTC, datetime
|
|
15
|
+
from typing import Any
|
|
16
|
+
from uuid import UUID, uuid4
|
|
17
|
+
|
|
18
|
+
from z4j_core.models import CommandResult, Schedule, ScheduleKind
|
|
19
|
+
|
|
20
|
+
from z4j_taskiqscheduler.capabilities import DEFAULT_CAPABILITIES
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger("z4j.agent.taskiqscheduler.scheduler")
|
|
23
|
+
|
|
24
|
+
_NAME = "taskiq-scheduler"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TaskiqSchedulerAdapter:
|
|
28
|
+
"""Scheduler adapter for taskiq schedule sources.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
source: A live ``ScheduleSource`` (e.g.
|
|
32
|
+
``taskiq.schedule_sources.LabelScheduleSource(broker)``)
|
|
33
|
+
that has been ``startup()``-ed.
|
|
34
|
+
project_id: Optional project id used when minting Schedule rows.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
name: str = _NAME
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
*,
|
|
42
|
+
source: Any,
|
|
43
|
+
project_id: UUID | None = None,
|
|
44
|
+
) -> None:
|
|
45
|
+
self.source = source
|
|
46
|
+
self._project_id = project_id or uuid4()
|
|
47
|
+
|
|
48
|
+
def connect_signals(self, sink: Any) -> None: # noqa: ARG002
|
|
49
|
+
return
|
|
50
|
+
|
|
51
|
+
def disconnect_signals(self) -> None:
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
async def list_schedules(self) -> list[Schedule]:
|
|
55
|
+
try:
|
|
56
|
+
scheduled = await self.source.get_schedules()
|
|
57
|
+
except Exception: # noqa: BLE001
|
|
58
|
+
logger.exception("z4j taskiqscheduler: get_schedules failed")
|
|
59
|
+
return []
|
|
60
|
+
out: list[Schedule] = []
|
|
61
|
+
for sch in scheduled:
|
|
62
|
+
try:
|
|
63
|
+
out.append(self._to_schedule(sch))
|
|
64
|
+
except Exception: # noqa: BLE001
|
|
65
|
+
logger.exception(
|
|
66
|
+
"z4j taskiqscheduler: failed to map %r",
|
|
67
|
+
getattr(sch, "schedule_id", "?"),
|
|
68
|
+
)
|
|
69
|
+
return out
|
|
70
|
+
|
|
71
|
+
async def get_schedule(self, schedule_id: str) -> Schedule | None:
|
|
72
|
+
for s in await self.list_schedules():
|
|
73
|
+
if s.external_id == schedule_id or str(s.id) == schedule_id:
|
|
74
|
+
return s
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
async def create_schedule(self, spec: Schedule) -> Schedule: # noqa: ARG002
|
|
78
|
+
raise NotImplementedError(
|
|
79
|
+
"taskiq schedules are decorator-defined; edit your "
|
|
80
|
+
"task's schedule= argument and redeploy.",
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
async def update_schedule(
|
|
84
|
+
self, schedule_id: str, spec: Schedule, # noqa: ARG002
|
|
85
|
+
) -> Schedule:
|
|
86
|
+
raise NotImplementedError(
|
|
87
|
+
"taskiq schedules are decorator-defined; edit and redeploy.",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
async def delete_schedule(self, schedule_id: str) -> CommandResult:
|
|
91
|
+
delete_fn = getattr(self.source, "delete_schedule", None)
|
|
92
|
+
if delete_fn is None:
|
|
93
|
+
return CommandResult(
|
|
94
|
+
status="failed",
|
|
95
|
+
error="this taskiq schedule source has no delete_schedule",
|
|
96
|
+
)
|
|
97
|
+
try:
|
|
98
|
+
await delete_fn(schedule_id)
|
|
99
|
+
except Exception as exc: # noqa: BLE001
|
|
100
|
+
return CommandResult(status="failed", error=str(exc))
|
|
101
|
+
return CommandResult(
|
|
102
|
+
status="success",
|
|
103
|
+
result={"schedule_id": schedule_id},
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
async def enable_schedule(self, schedule_id: str) -> CommandResult: # noqa: ARG002
|
|
107
|
+
return CommandResult(
|
|
108
|
+
status="failed",
|
|
109
|
+
error=(
|
|
110
|
+
"taskiq schedules have no enable/disable toggle — "
|
|
111
|
+
"delete + re-add to suspend"
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
async def disable_schedule(self, schedule_id: str) -> CommandResult: # noqa: ARG002
|
|
116
|
+
return CommandResult(
|
|
117
|
+
status="failed",
|
|
118
|
+
error="taskiq schedules have no enable/disable toggle",
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
async def trigger_now(self, schedule_id: str) -> CommandResult: # noqa: ARG002
|
|
122
|
+
return CommandResult(
|
|
123
|
+
status="failed",
|
|
124
|
+
error=(
|
|
125
|
+
"taskiq has no scheduler trigger-now primitive; "
|
|
126
|
+
"kick the underlying task via broker.find_task(...).kiq()"
|
|
127
|
+
),
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
def capabilities(self) -> set[str]:
|
|
131
|
+
return set(DEFAULT_CAPABILITIES)
|
|
132
|
+
|
|
133
|
+
def _to_schedule(self, sch: Any) -> Schedule:
|
|
134
|
+
now = datetime.now(UTC)
|
|
135
|
+
sid = uuid4()
|
|
136
|
+
cron_expr = getattr(sch, "cron", None)
|
|
137
|
+
time_at = getattr(sch, "time", None)
|
|
138
|
+
interval = getattr(sch, "interval", None)
|
|
139
|
+
if cron_expr:
|
|
140
|
+
kind = ScheduleKind.CRON
|
|
141
|
+
expression = str(cron_expr)
|
|
142
|
+
elif interval is not None:
|
|
143
|
+
kind = ScheduleKind.INTERVAL
|
|
144
|
+
expression = str(interval)
|
|
145
|
+
elif time_at is not None:
|
|
146
|
+
kind = ScheduleKind.CLOCKED
|
|
147
|
+
expression = (
|
|
148
|
+
time_at.isoformat()
|
|
149
|
+
if hasattr(time_at, "isoformat")
|
|
150
|
+
else str(time_at)
|
|
151
|
+
)
|
|
152
|
+
else:
|
|
153
|
+
kind = ScheduleKind.CRON
|
|
154
|
+
expression = "unknown"
|
|
155
|
+
return Schedule(
|
|
156
|
+
id=sid,
|
|
157
|
+
project_id=self._project_id,
|
|
158
|
+
engine="taskiq",
|
|
159
|
+
scheduler=self.name,
|
|
160
|
+
name=getattr(sch, "task_name", None) or "taskiq-schedule",
|
|
161
|
+
task_name=getattr(sch, "task_name", None) or "taskiq-task",
|
|
162
|
+
kind=kind,
|
|
163
|
+
expression=expression,
|
|
164
|
+
timezone="UTC",
|
|
165
|
+
args=list(getattr(sch, "args", []) or []),
|
|
166
|
+
kwargs=dict(getattr(sch, "kwargs", {}) or {}),
|
|
167
|
+
is_enabled=True,
|
|
168
|
+
external_id=getattr(sch, "schedule_id", None) or str(sid),
|
|
169
|
+
created_at=now,
|
|
170
|
+
updated_at=now,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
__all__ = ["TaskiqSchedulerAdapter"]
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""TaskiqSchedulerAdapter tests using LabelScheduleSource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
pytest.importorskip("taskiq")
|
|
8
|
+
|
|
9
|
+
from taskiq import InMemoryBroker # noqa: E402
|
|
10
|
+
from taskiq.schedule_sources import LabelScheduleSource # noqa: E402
|
|
11
|
+
|
|
12
|
+
from z4j_taskiqscheduler import TaskiqSchedulerAdapter # noqa: E402
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
def broker():
|
|
17
|
+
b = InMemoryBroker()
|
|
18
|
+
|
|
19
|
+
@b.task(schedule=[{"cron": "*/5 * * * *"}])
|
|
20
|
+
async def cleanup():
|
|
21
|
+
return "ok"
|
|
22
|
+
|
|
23
|
+
@b.task(schedule=[{"cron": "0 3 * * *"}])
|
|
24
|
+
async def nightly():
|
|
25
|
+
return "ok"
|
|
26
|
+
|
|
27
|
+
return b
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.fixture
|
|
31
|
+
async def source(broker):
|
|
32
|
+
s = LabelScheduleSource(broker)
|
|
33
|
+
await s.startup()
|
|
34
|
+
yield s
|
|
35
|
+
await s.shutdown()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.fixture
|
|
39
|
+
def adapter(source):
|
|
40
|
+
return TaskiqSchedulerAdapter(source=source)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@pytest.mark.asyncio
|
|
44
|
+
async def test_lists_decorator_defined_schedules(adapter):
|
|
45
|
+
rows = await adapter.list_schedules()
|
|
46
|
+
assert len(rows) >= 2
|
|
47
|
+
crons = {r.expression for r in rows}
|
|
48
|
+
assert "*/5 * * * *" in crons
|
|
49
|
+
assert "0 3 * * *" in crons
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@pytest.mark.asyncio
|
|
53
|
+
async def test_engine_and_scheduler_set(adapter):
|
|
54
|
+
rows = await adapter.list_schedules()
|
|
55
|
+
assert all(r.engine == "taskiq" for r in rows)
|
|
56
|
+
assert all(r.scheduler == "taskiq-scheduler" for r in rows)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@pytest.mark.asyncio
|
|
60
|
+
async def test_get_by_external_id(adapter):
|
|
61
|
+
rows = await adapter.list_schedules()
|
|
62
|
+
target = rows[0]
|
|
63
|
+
found = await adapter.get_schedule(target.external_id)
|
|
64
|
+
assert found is not None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pytest.mark.asyncio
|
|
68
|
+
async def test_create_raises_not_implemented(adapter):
|
|
69
|
+
with pytest.raises(NotImplementedError):
|
|
70
|
+
await adapter.create_schedule(spec=None) # type: ignore[arg-type]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.asyncio
|
|
74
|
+
async def test_enable_clearly_unsupported(adapter):
|
|
75
|
+
res = await adapter.enable_schedule("anything")
|
|
76
|
+
assert res.status == "failed"
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@pytest.mark.asyncio
|
|
80
|
+
async def test_trigger_clearly_unsupported(adapter):
|
|
81
|
+
res = await adapter.trigger_now("anything")
|
|
82
|
+
assert res.status == "failed"
|