Skip to content

Commit 2421985

Browse files
committed
Rename plain-worker to plain-jobs
1 parent 905a294 commit 2421985

Some content is hidden

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

42 files changed

+370
-119
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ With the official Plain ecosystem packages you can:
3131
- Style with [Tailwind CSS](https://plainframework.com/docs/plain-tailwind/plain/tailwind/README.md)
3232
- Add [OAuth login](https://plainframework.com/docs/plain-oauth/plain/oauth/README.md) and API access
3333
- Run tests with [pytest](https://plainframework.com/docs/plain-pytest/plain/pytest/README.md)
34-
- Run a [background job worker](https://plainframework.com/docs/plain-worker/plain/worker/README.md)
34+
- Run a [background job worker](https://plainframework.com/docs/plain-jobs/plain/jobs/README.md)
3535
- Build [admin dashboard and tools](https://plainframework.com/docs/plain-admin/plain/admin/README.md)
3636

3737
Learn more at [plainframework.com](https://plainframework.com).

example/app/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"plain.email",
1212
"plain.flags",
1313
"plain.htmx",
14+
"plain.jobs",
1415
"plain.loginlink",
1516
"plain.models",
1617
"plain.oauth",
@@ -21,7 +22,6 @@
2122
"plain.support",
2223
"plain.tailwind",
2324
"plain.toolbar",
24-
"plain.worker",
2525
"plain.redirection",
2626
"plain.observer",
2727
"app.users",

example/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies = [
1515
"plain-esbuild",
1616
"plain-flags",
1717
"plain-htmx",
18+
"plain-jobs",
1819
"plain-loginlink",
1920
"plain-email",
2021
"plain-models",
@@ -30,7 +31,6 @@ dependencies = [
3031
"plain-toolbar",
3132
"plain-tunnel",
3233
"plain-vendor",
33-
"plain-worker",
3434
"plain-observer",
3535
]
3636

plain-dev/plain/dev/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ postgres = {cmd = "docker run --name app-postgres --rm -p 54321:5432 -v $(pwd)/.
6161

6262
#### Custom processes
6363

64-
Unlike [services](#services), custom processes are _only_ run during `plain dev`. This is a good place to run something like [ngrok](https://ngrok.com/) or a [Plain worker](../../../plain-worker), which you might need to use your local site, but don't need running for executing tests, for example.
64+
Unlike [services](#services), custom processes are _only_ run during `plain dev`. This is a good place to run something like [ngrok](https://ngrok.com/) or a [Plain job worker](../../../plain-jobs), which you might need to use your local site, but don't need running for executing tests, for example.
6565

6666
```toml
6767
# pyproject.toml
File renamed without changes.
File renamed without changes.

plain-jobs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./plain/jobs/README.md
File renamed without changes.

plain-worker/plain/worker/README.md renamed to plain-jobs/plain/jobs/README.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# plain.worker
1+
# plain.jobs
22

3-
**Process background jobs with a database-driven worker.**
3+
**Process background jobs with a database-driven job queue.**
44

55
- [Overview](#overview)
66
- [Local development](#local-development)
@@ -18,7 +18,7 @@
1818
Jobs are defined using the [`Job`](./jobs.py#Job) base class and the `run()` method at a minimum.
1919

2020
```python
21-
from plain.worker import Job, register_job
21+
from plain.jobs import Job, register_job
2222
from plain.email import send_mail
2323

2424

@@ -43,7 +43,7 @@ user = User.query.get(id=1)
4343
WelcomeUserJob(user).run_in_worker()
4444
```
4545

46-
Workers are run using the `plain worker run` command.
46+
Workers are run using the `plain jobs worker` command.
4747

4848
Jobs can be defined in any Python file, but it is suggested to use `app/jobs.py` or `app/{pkg}/jobs.py` as those will be imported automatically so the [`@register_job`](./registry.py#register_job) decorator will fire.
4949

@@ -60,8 +60,8 @@ In development, you will typically want to run the worker alongside your app. Wi
6060
```toml
6161
# pyproject.toml
6262
[tool.plain.dev.run]
63-
worker = {cmd = "watchfiles --filter python \"plain worker run --stats-every 0 --max-processes 2\" ."}
64-
worker-slow = {cmd = "watchfiles --filter python \"plain worker run --queue slow --stats-every 0 --max-processes 2\" ."}
63+
worker = {cmd = "watchfiles --filter python \"plain jobs worker --stats-every 0 --max-processes 2\" ."}
64+
worker-slow = {cmd = "watchfiles --filter python \"plain jobs worker --queue slow --stats-every 0 --max-processes 2\" ."}
6565
```
6666

6767
## Job parameters
@@ -118,8 +118,8 @@ class MyJob(Job):
118118
You can schedule jobs to run at specific times using the [`Schedule`](./scheduling.py#Schedule) class:
119119

120120
```python
121-
from plain.worker import Job, register_job
122-
from plain.worker.scheduling import Schedule
121+
from plain.jobs import Job, register_job
122+
from plain.jobs.scheduling import Schedule
123123

124124
@register_job
125125
class DailyReportJob(Job):
@@ -142,13 +142,13 @@ For custom schedules, see [`Schedule`](./scheduling.py#Schedule).
142142

143143
## Admin interface
144144

145-
The worker package includes admin views for monitoring jobs. The admin interface provides:
145+
The jobs package includes admin views for monitoring jobs under the "Jobs" section. The admin interface provides:
146146

147-
- **Job Requests**: View pending jobs in the queue
148-
- **Jobs**: Monitor currently running jobs
149-
- **Job Results**: Review completed and failed job history
147+
- **Requests**: View pending jobs in the queue
148+
- **Processes**: Monitor currently running jobs
149+
- **Results**: Review completed and failed job history
150150

151-
Dashboard cards show at-a-glance statistics for successful and errored jobs.
151+
Dashboard cards show at-a-glance statistics for successful, errored, lost, and retried jobs.
152152

153153
## Job history
154154

@@ -160,11 +160,18 @@ Job execution history is stored in the [`JobResult`](./models.py#JobResult) mode
160160
- Error messages and tracebacks for failed jobs
161161
- Worker information
162162

163-
History retention can be configured in your settings:
163+
History retention is controlled by the `JOBS_RESULTS_RETENTION` setting (defaults to 7 days):
164164

165165
```python
166166
# app/settings.py
167-
WORKER_JOB_HISTORY_DAYS = 30
167+
JOBS_RESULTS_RETENTION = 60 * 60 * 24 * 30 # 30 days (in seconds)
168+
```
169+
170+
Job timeout can be configured with `JOBS_TIMEOUT` (defaults to 1 day):
171+
172+
```python
173+
# app/settings.py
174+
JOBS_TIMEOUT = 60 * 60 * 24 # 1 day (in seconds)
168175
```
169176

170177
## Monitoring
@@ -173,7 +180,7 @@ Workers report statistics and can be monitored using the `--stats-every` option:
173180

174181
```bash
175182
# Report stats every 60 seconds
176-
plain worker run --stats-every 60
183+
plain jobs worker --stats-every 60
177184
```
178185

179186
The worker integrates with OpenTelemetry for distributed tracing. Spans are created for:
@@ -204,13 +211,13 @@ class ProcessUserDataJob(Job):
204211
Yes, you can run multiple worker processes:
205212

206213
```bash
207-
plain worker run --max-processes 4
214+
plain jobs worker --max-processes 4
208215
```
209216

210217
Or run workers for specific queues:
211218

212219
```bash
213-
plain worker run --queue slow --max-processes 2
220+
plain jobs worker --queue slow --max-processes 2
214221
```
215222

216223
#### How do I handle job failures?
@@ -229,10 +236,10 @@ class MyJob(Job):
229236

230237
## Installation
231238

232-
Install the `plain.worker` package from [PyPI](https://pypi.org/project/plain.worker/):
239+
Install the `plain.jobs` package from [PyPI](https://pypi.org/project/plain.jobs/):
233240

234241
```bash
235-
uv add plain.worker
242+
uv add plain.jobs
236243
```
237244

238245
Add to your `INSTALLED_PACKAGES`:
@@ -241,6 +248,6 @@ Add to your `INSTALLED_PACKAGES`:
241248
# app/settings.py
242249
INSTALLED_PACKAGES = [
243250
...
244-
"plain.worker",
251+
"plain.jobs",
245252
]
246253
```
File renamed without changes.

0 commit comments

Comments
 (0)