Skip to content

Commit 5b71106

Browse files
committed
feat:rename *Job to *Task
1 parent 23bb2d5 commit 5b71106

22 files changed

+555
-440
lines changed

docs/changelog.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# Changelog
22

3+
## v1.2.0 🌈
4+
5+
### 🚀 Features
6+
7+
- Rename `*Job` models to `*Task` to differentiate.
8+
9+
310
## v1.1.0 🌈
411

512
### 🚀 Features
613

714
- Enable using stats view using api token
15+
- Reverted, active jobs are not marked as scheduled as there is currently no new job instance for them.
816

917
### 🐛 Bug Fixes
1018

docs/commands.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ python manage.py rqworker queue1 queue2 queue3
1414

1515
## export
1616

17-
Export all scheduled jobs from django db to json/yaml format.
17+
Export all scheduled tasks from django db to json/yaml format.
1818

1919
```shell
2020
python manage.py export -o {yaml,json}
@@ -26,7 +26,7 @@ Result should be (for json):
2626
[
2727
{
2828
"model": "ScheduledJob",
29-
"name": "Scheduled Job 1",
29+
"name": "Scheduled Task 1",
3030
"callable": "scheduler.tests.test_job",
3131
"callable_args": [
3232
{
@@ -52,7 +52,7 @@ A json/yaml that was exported using the `export` command
5252
can be imported to django.
5353

5454
- Specify the source file using `--filename` or take it from the standard input (default).
55-
- Reset all scheduled jobs in the database before importing using `-r`/`--reset`.
55+
- Reset all scheduled tasks in the database before importing using `-r`/`--reset`.
5656
- Update existing jobs for names that are found using `-u`/`--update`.
5757

5858
```shell

docs/index.md

+21-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
---
99

1010
A database backed async tasks scheduler for django.
11-
This allows remembering scheduled jobs, their parameters, etc.
11+
This allows remembering scheduled tasks, their parameters, etc.
1212

1313
## Terminology
1414

@@ -17,7 +17,7 @@ This allows remembering scheduled jobs, their parameters, etc.
1717
A queue of messages between processes (main django-app process and worker usually).
1818
This is implemented in `rq` package.
1919

20-
* A queue contains multiple registries for scheduled jobs, finished jobs, failed jobs, etc.
20+
* A queue contains multiple registries for scheduled tasks, finished jobs, failed jobs, etc.
2121

2222
### Worker
2323

@@ -36,26 +36,26 @@ This is a sub-process of worker.
3636
Once a worker listening to the queue becomes available,
3737
the job will be executed
3838

39-
### Scheduled Job Execution
39+
### Scheduled Task Execution
4040

4141
A scheduler checking the queue periodically will check
4242
whether the time the job should be executed has come, and if so, it will queue it.
4343

4444
* A job is considered scheduled if it is queued to be executed, or scheduled to be executed.
4545
* If there is no scheduler, the job will not be queued to run.
4646

47-
### Scheduled Job
47+
### Scheduled Task
4848

4949
django models storing information about jobs. So it is possible to schedule using
5050
django-admin and track their status.
5151

52-
There are 3 types of scheduled job.
52+
There are 3 types of scheduled task.
5353

54-
* `Scheduled Job` - Run a job once, on a specific time (can be immediate).
55-
* `Repeatable Job` - Run a job multiple times (limited number of times or infinite times) based on an interval
56-
* `Cron Job` - Run a job multiple times (limited number of times or infinite times) based on a cron string
54+
* `Scheduled Task` - Run a job once, on a specific time (can be immediate).
55+
* `Repeatable Task` - Run a job multiple times (limited number of times or infinite times) based on an interval
56+
* `Cron Task` - Run a job multiple times (limited number of times or infinite times) based on a cron string
5757

58-
Scheduled jobs are scheduled when the django application starts, and after a scheduled job is executed.
58+
Scheduled jobs are scheduled when the django application starts, and after a scheduled task is executed.
5959

6060
## Scheduler sequence diagram
6161

@@ -65,12 +65,22 @@ sequenceDiagram
6565
box Worker
6666
participant scheduler as Scheduler Process
6767
end
68+
box DB
69+
participant db as Database
70+
71+
end
6872
box Redis queue
6973
participant queue as Queue
70-
participant schedule as Queue scheduled jobs
74+
participant schedule as Queue scheduled tasks
7175
end
7276
loop Scheduler process - loop forever
73-
scheduler ->> schedule: check whether there are jobs that should be scheduled for execution
77+
note over scheduler,schedule: Database interaction
78+
scheduler ->> db: Check for enabled tasks that should be scheduled
79+
critical There are tasks to be scheduled
80+
scheduler ->> schedule: Create a job for task that should be scheduled
81+
end
82+
note over scheduler,schedule: Redis queues interaction
83+
scheduler ->> schedule: check whether there are scheduled tasks that should be executed
7484
critical there are jobs that are scheduled to be executed
7585
scheduler ->> schedule: remove jobs to be scheduled
7686
scheduler ->> queue: enqueue jobs to be executed

docs/usage.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ RQ = {
5353

5454
* Sign in to the Django Admin site (e.g., http://localhost:8000/admin/) and locate the
5555
**Tasks Scheduler** section.
56-
* Click on the **Add** link for the type of job you want to add (`Scheduled Job` - run once, `Repeatable Job` - run
57-
multiple times, `Cron Job` - Run based on cron schedule).
56+
* Click on the **Add** link for the type of job you want to add (`Scheduled Task` - run once, `Repeatable Task` - run
57+
multiple times, `Cron Task` - Run based on cron schedule).
5858
* Enter a unique name for the job in the **Name** field.
5959
* In the **Callable** field, enter a Python dot notation path to the method that defines the job. For the example
6060
above, that would be `myapp.jobs.count`
@@ -83,11 +83,11 @@ calculated in runtime.
8383

8484
![](media/add-args.jpg)
8585

86-
### Scheduled Job - run once
86+
### Scheduled Task - run once
8787

8888
No additional steps required.
8989

90-
### Repeatable Job - Run a job multiple time based on interval
90+
### Repeatable Task - Run a job multiple time based on interval
9191

9292
Additional fields required:
9393

@@ -96,19 +96,19 @@ Additional fields required:
9696
* In the **Repeat** field, enter the number of time the job is to be run. Leaving the field empty, means the job will
9797
be scheduled to run forever.
9898

99-
### Cron Job - Run a job multiple time based on cron
99+
### Cron Task - Run a job multiple time based on cron
100100

101101
Additional fields required:
102102

103103
* In the **Repeat** field, enter the number of time the job is to be run. Leaving the field empty, means the job will be
104104
scheduled to run forever.
105105
* In the **cron string** field, enter a cron string describing how often the job should run.
106106

107-
### Scheduled Job - run once
107+
### Scheduled Task - run once
108108

109109
No additional steps required.
110110

111-
### Repeatable Job - Run a job multiple time based on interval
111+
### Repeatable Task - Run a job multiple time based on interval
112112

113113
Additional fields required:
114114

@@ -117,7 +117,7 @@ Additional fields required:
117117
* In the **Repeat** field, enter the number of time the job is to be run. Leaving the field empty, means the job will
118118
be scheduled to run forever.
119119

120-
### Cron Job - Run a job multiple time based on cron
120+
### Cron Task - Run a job multiple time based on cron
121121

122122
Additional fields required:
123123

@@ -177,12 +177,14 @@ WantedBy = multi-user.target
177177
```
178178

179179
After you are done editing the file, reload the settings and start the new workers:
180+
180181
```shell
181182
sudo systemctl daemon-reload
182183
sudo systemctl start rqworker@{1..3}
183184
```
184185

185186
You can target a specific worker using its number:
187+
186188
```shell
187189
sudo systemctl stop rqworker@2
188190
```

0 commit comments

Comments
 (0)