Skip to content

Commit 5502c11

Browse files
committed
Merge branch 'master' of https://github.com/taskiq-python/taskiq
1 parent 79c15e5 commit 5502c11

File tree

32 files changed

+2110
-1447
lines changed

32 files changed

+2110
-1447
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ jobs:
99
deploy:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v5
13+
with:
14+
persist-credentials: false
1315
- name: Install poetry
1416
run: pipx install poetry
1517
- name: Set up Python
16-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v6
1719
with:
1820
python-version: "3.11"
1921
- name: Install deps
2022
run: poetry install
2123
- name: Set version
22-
run: poetry version "${{ github.ref_name }}"
24+
run: poetry version "${GITHUB_REF_NAME}"
2325
- name: Release package
2426
env:
2527
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}

.github/workflows/release_docs.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ jobs:
1313
deploy_docs:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
17+
with:
18+
persist-credentials: false
1719
- name: Setup pnpm
18-
uses: pnpm/action-setup@v2
20+
uses: pnpm/action-setup@v4
1921
- name: Setup Node.js
20-
uses: actions/setup-node@v3
22+
uses: actions/setup-node@v6
2123
with:
2224
node-version: 18
2325
cache: pnpm
@@ -31,7 +33,7 @@ jobs:
3133
git config --global lfs.allowincompletepush true
3234
3335
- name: Deploy
34-
uses: peaceiris/actions-gh-pages@v3
36+
uses: peaceiris/actions-gh-pages@v4
3537
with:
3638
personal_token: ${{ secrets.PERSONAL_TOKEN }}
3739
external_repository: taskiq-python/taskiq-python.github.io

.github/workflows/test.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ name: Testing taskiq
22

33
on:
44
pull_request:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '*.md'
58
push:
9+
paths-ignore:
10+
- 'docs/**'
11+
- '*.md'
12+
13+
permissions:
14+
actions: read
15+
contents: read
16+
pull-requests: read
617

718
jobs:
819
lint:
@@ -14,11 +25,13 @@ jobs:
1425
- mypy
1526
runs-on: ubuntu-latest
1627
steps:
17-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v5
29+
with:
30+
persist-credentials: false
1831
- name: Install poetry
1932
run: pipx install poetry
2033
- name: Set up Python
21-
uses: actions/setup-python@v4
34+
uses: actions/setup-python@v6
2235
with:
2336
python-version: "3.11"
2437
cache: "poetry"
@@ -34,11 +47,13 @@ jobs:
3447
os: [ubuntu-latest, windows-latest, macos-latest]
3548
runs-on: "${{ matrix.os }}"
3649
steps:
37-
- uses: actions/checkout@v2
50+
- uses: actions/checkout@v5
51+
with:
52+
persist-credentials: false
3853
- name: Install poetry
3954
run: pipx install poetry
4055
- name: Set up Python
41-
uses: actions/setup-python@v4
56+
uses: actions/setup-python@v6
4257
with:
4358
python-version: "${{ matrix.py_version }}"
4459
cache: "poetry"

.pre-commit-config.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,33 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v2.4.0
5+
rev: v6.0.0
66
hooks:
77
- id: check-ast
88
- id: trailing-whitespace
99
- id: check-toml
1010
- id: end-of-file-fixer
1111

1212
- repo: https://github.com/asottile/add-trailing-comma
13-
rev: v2.1.0
13+
rev: v4.0.0
1414
hooks:
1515
- id: add-trailing-comma
1616

17+
- repo: https://github.com/crate-ci/typos
18+
rev: v1.38.1
19+
hooks:
20+
- id: typos
21+
22+
- repo: https://github.com/Yelp/detect-secrets
23+
rev: v1.5.0
24+
hooks:
25+
- id: detect-secrets
26+
args: [
27+
'--exclude-files', 'pnpm-lock.yaml',
28+
'--exclude-files', 'docs/README.md',
29+
'--exclude-lines', 'amqp://guest:guest@localhost:5672',
30+
]
31+
1732
- repo: local
1833
hooks:
1934
- id: black

docs/available-components/brokers.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ await my_task.kicker().with_broker(broker).kiq()
8282

8383
## Custom brokers
8484

85-
These brokers are not parts of the core taskiq lib. You can install them as a separate packages.
85+
These brokers are not parts of the core Taskiq lib. But they are maintained by Taskiq developers.
86+
You can install them as a separate packages.
8687

8788
You can read more about parameters and abilities of these brokers in README.md of each repo.
8889

@@ -110,3 +111,33 @@ Project link: [taskiq-nats](https://github.com/taskiq-python/taskiq-nats).
110111
```bash
111112
pip install taskiq-nats
112113
```
114+
115+
## Third-party brokers
116+
117+
These brokers are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
118+
119+
You can read more about parameters and abilities of these brokers in README.md of each repo.
120+
121+
### PostgreSQL broker
122+
123+
Project link: [taskiq-postgresql](https://github.com/z22092/taskiq-postgresql).
124+
125+
```bash
126+
pip install taskiq-postgresql
127+
```
128+
129+
### SQS broker
130+
131+
Project link: [taskiq-aio-sqs](https://github.com/vonsteer/taskiq-aio-sqs).
132+
133+
```bash
134+
pip install taskiq-aio-sqs
135+
```
136+
137+
### YDB broker
138+
139+
Project link: [taskiq-ydb](https://github.com/danfimov/taskiq-ydb).
140+
141+
```bash
142+
pip install taskiq-ydb
143+
```

docs/available-components/result-backends.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,60 @@ This includes:
1010
- return value;
1111
- Execution time in seconds.
1212

13-
## DummyResultBackend
13+
## Built-in result backends
14+
15+
### DummyResultBackend
1416

1517
This result backend doesn't do anything. It doesn't store results and cannot be used in cases,
1618
where you need actual results.
1719

1820
This broker will always return `None` for any return_value. Please be careful.
1921

20-
## Redis result backend
2122

22-
This result backend is not part of the core taskiq library. You can install it as a separate package [taskiq-redis](https://pypi.org/project/taskiq-redis/).
23+
## Official result backends
24+
25+
This result backends is not part of the core Taskiq library. But they are maintained by Taskiq developers. You can install them as a separate package.
26+
27+
### Redis result backend
28+
29+
Project link: [taskiq-redis](https://pypi.org/project/taskiq-redis/).
2330

2431
```bash
2532
pip install taskiq-redis
2633
```
2734

28-
You can read more about parameters and abilities of this broker in [README.md](https://github.com/taskiq-python/taskiq-redis).
35+
### NATS result backend
36+
37+
Project link: [taskiq-nats](https://github.com/taskiq-python/taskiq-nats).
38+
39+
```bash
40+
pip install taskiq-nats
41+
```
42+
43+
## Third-party result backends
44+
45+
These result backends are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
46+
47+
### PostgreSQL result backend
48+
49+
Project link: [taskiq-postgresql](https://github.com/z22092/taskiq-postgresql).
50+
51+
```bash
52+
pip install taskiq-postgresql
53+
```
54+
55+
### S3 result backend
56+
57+
Project link: [taskiq-aio-sqs](https://github.com/vonsteer/taskiq-aio-sqs).
58+
59+
```bash
60+
pip install taskiq-aio-sqs
61+
```
62+
63+
### YDB result backend
64+
65+
Project link: [taskiq-ydb](https://github.com/danfimov/taskiq-ydb).
66+
67+
```bash
68+
pip install taskiq-ydb
69+
```

docs/available-components/schedule-sources.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ order: 4
55
# Available schedule sources
66

77
These objects are used to fetch current schedule for tasks.
8-
Currently we have only one schedule source.
98

10-
## RedisScheduleSource
9+
## Official schedule sources
10+
11+
These schedule sources are not part of the core Taskiq library. But they are maintained by Taskiq developers. You can install them as a separate package.
12+
13+
### RedisScheduleSource
1114

1215
This source is capable of adding new schedules in runtime. It uses Redis as a storage for schedules.
1316
To use this source you need to install `taskiq-redis` package.
@@ -24,7 +27,7 @@ scheduler = TaskiqScheduler(broker, sources=[redis_source])
2427
For more information on how to use dynamic schedule sources read [Dynamic scheduling section](../guide/scheduling-tasks.md#dynamic-scheduling).
2528

2629

27-
## LabelScheduleSource
30+
### LabelScheduleSource
2831

2932
This source parses labels of tasks, and if it finds a `schedule` label, it considers this task as scheduled.
3033

@@ -34,12 +37,13 @@ The format of the schedule label is the following:
3437
@broker.task(
3538
schedule=[
3639
{
37-
"cron": "* * * * *", # type: str, either cron or time should be specified.
40+
"cron": "*/1 * * * *", # type: str, either cron or time should be specified.
3841
"cron_offset": None # type: str | timedelta | None, can be omitted.
3942
"time": None # type: datetime | None, either cron or time should be specified.
4043
"args": [], # type List[Any] | None, can be omitted.
4144
"kwargs": {}, # type: Dict[str, Any] | None, can be omitted.
4245
"labels": {}, # type: Dict[str, Any] | None, can be omitted.
46+
"schedule_id": "every_minute", # type: str | None, can be omitted.
4347
}
4448
]
4549
)
@@ -55,6 +59,7 @@ Parameters:
5559
- `args` - args to use, when invoking the task.
5660
- `kwargs` - key-word arguments to use when invoking the task.
5761
- `labels` - additional labels to use when invoking the task.
62+
- `schedule_id` - unique identifier of the schedule. If not specified, a random uuid will be generated.
5863

5964
To enable this source, just add it to the list of sources:
6065

@@ -76,3 +81,43 @@ In order to resolve all labels correctly, don't forget to import
7681
all task modules using CLI interface.
7782

7883
:::
84+
85+
### NATS schedule source
86+
87+
This source is capable of adding new schedules in runtime. It uses NATS as a storage for schedules.
88+
To use this source you need to install `taskiq-nats` package.
89+
90+
```python
91+
from taskiq_nats import NATSKeyValueScheduleSource
92+
from taskiq.scheduler import TaskiqScheduler
93+
94+
95+
broker = ...
96+
97+
scheduler = TaskiqScheduler(
98+
broker=broker,
99+
sources=[NATSKeyValueScheduleSource(broker)],
100+
)
101+
```
102+
103+
This schedule source doesn't use `schedule` label on tasks. To add new schedules, you need to call `add_schedule` method on the source.
104+
105+
## Third-party schedule sources
106+
107+
These schedule sources are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
108+
109+
### PostgreSQL schedule source
110+
111+
Project link: [taskiq-postgres](https://github.com/danfimov/taskiq-postgres)
112+
113+
```bash
114+
pip install taskiq-postgres
115+
```
116+
117+
### YDB schedule source
118+
119+
Project link: [taskiq-ydb](https://github.com/danfimov/taskiq-ydb)
120+
121+
```bash
122+
pip install taskiq-ydb
123+
```

docs/extending-taskiq/schedule-sources.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ Here's a minimal example of a schedule source:
1212
@[code python](../examples/extending/schedule_source.py)
1313

1414
You can implement a schedule source that write schedules in the database and have delayed tasks in runtime.
15+
16+
::: info Cool tip!
17+
You can also use `LabelScheduleSource` as a base class for your schedule source
18+
if you want to parse schedules from task labels and don't want to implement logic for this from scratch.
19+
:::

docs/guide/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ We created this project because we couldn't find any project that can execute an
2121

2222
You might have seen projects built on top of asyncio that solve a similar problem, but here's a comparison table of the taskiq and other projects.
2323

24-
| Feature name | Taskiq | Arq | AioTasks |
25-
| --------------------------: | :----: | :---: | :------: |
26-
| Actively maintained ||||
27-
| Multiple broker backends ||||
28-
| Multiple result backends ||||
29-
| Have a rich documentation ||||
30-
| Startup & Shutdown events ||||
31-
| Have ability to abort tasks ||||
32-
| Custom serializers ||||
33-
| Dependency injection ||||
34-
| Task pipelines ||||
35-
| Task schedules ||||
36-
| Global middlewares ||||
24+
| Feature name | Taskiq | Arq | AioTasks | streaQ |
25+
| --------------------------: | :----: | :---: | :------: | :----: |
26+
| Actively maintained |||||
27+
| Multiple broker backends |||||
28+
| Multiple result backends |||||
29+
| Have a rich documentation |||||
30+
| Startup & Shutdown events |||||
31+
| Have ability to abort tasks |||||
32+
| Custom serializers |||||
33+
| Dependency injection |||||
34+
| Task pipelines |||||
35+
| Task schedules |||||
36+
| Global middlewares |||||
3737

3838
If you have a fully synchronous project, consider using celery or dramatiq instead.

docs/guide/scheduling-tasks.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ The scheduler doesn't execute tasks. It only sends them.
5353

5454
You can check list of available schedule sources in the [Available schedule sources](../available-components/schedule-sources.md) section.
5555

56+
::: tip Cool tip!
57+
58+
To specify schedules (cron or time-based) in the labels of a task definition, you must include **LabelScheduleSource** along with any other sources you use (e.g., **ListRedisScheduleSource**).
59+
60+
:::
61+
5662
## Multiple sources
5763

5864
Sometimes you may want to use multiple sources to assemble a schedule for tasks. The `TaskiqScheduler` can do so.

0 commit comments

Comments
 (0)