Skip to content

Commit d9c6ea3

Browse files
committed
[!] transform Sphinx manual to mkdocs-material
1 parent f675892 commit d9c6ea3

22 files changed

+744
-727
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Go Build & Test
22
on:
33
pull_request:
4+
paths-ignore:
5+
- 'docs/**'
6+
- 'mkdocs.yml'
47
workflow_dispatch:
58

69
concurrency:

.github/workflows/docs.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy MkDocs Documentation
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- 'docs/**'
8+
- 'mkdocs.yml'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Python
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: '3.x'
31+
32+
- name: Install dependencies
33+
run: |
34+
pip install mkdocs-material
35+
pip install mkdocstrings[python]
36+
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v3
39+
40+
- name: Build with MkDocs
41+
run: mkdocs build --config-file mkdocs.yml
42+
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v2
45+
with:
46+
path: ./site
47+
48+
deploy:
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
runs-on: ubuntu-latest
53+
needs: build
54+
steps:
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v2

docs/README.rst

Lines changed: 0 additions & 120 deletions
This file was deleted.

docs/api.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# REST API
2+
3+
**pg_timetable** has a rich REST API, which can be used by external tools in order to perform start/stop/reinitialize/restarts/reloads,
4+
by any kind of tools to perform HTTP health checks, and of course, could also be used for monitoring.
5+
6+
Below you will find the list of **pg_timetable** REST API endpoints.
7+
8+
## Health check endpoints
9+
10+
### `GET /liveness`
11+
Always returns HTTP status code `200`, indicating that **pg_timetable** is running.
12+
13+
### `GET /readiness`
14+
Returns HTTP status code `200` when the **pg_timetable** is running, and the scheduler is in the main loop processing chains.
15+
If the scheduler connects to the database, creates the database schema, or upgrades it, it will return the HTTP status code `503`.
16+
17+
## Chain management endpoints
18+
19+
### `GET /startchain?id=<chain-id>`
20+
Returns HTTP status code `200` if the chain with the given id can be added to the worker queue. It doesn't, however, mean the chain execution starts immediately. It is up to the worker to perform load and other checks before starting the chain.
21+
In the case of an error, the HTTP status code `400` followed by an error message returned.
22+
23+
### `GET /stopchain?id=<chain-id>`
24+
Returns HTTP status code `200` if the chain with the given id is working at the moment and can be stopped. If the chain is running the
25+
cancel signal would be sent immediately.
26+
In the case of an error, the HTTP status code `400` followed by an error message returned.

docs/api.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/background.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Project background
2+
3+
The pg_timetable project got started back in 2019 for internal scheduling needs at Cybertec.
4+
5+
For more background on the project motivations and design goals see the original series of blogposts announcing the project
6+
and the following feature updates.
7+
8+
Cybertec also provides commercial 9-to-5 and 24/7 support for pg_timetable.
9+
10+
* [Project announcement](https://www.cybertec-postgresql.com/en/pg_timetable-advanced-postgresql-job-scheduling/)
11+
12+
* [v2 released](https://www.cybertec-postgresql.com/en/pg_timetable-advanced-postgresql-cron-like-scheduler-released/)
13+
14+
* [Start-up improvements](https://www.cybertec-postgresql.com/en/pg_timetable-start-up-improvements/)
15+
16+
* [v3 released](https://www.cybertec-postgresql.com/en/pg_timetable-v3-is-out/)
17+
18+
* [Exclusive jobs explained](https://www.cybertec-postgresql.com/en/postgresql-exclusive-cron-jobs-using-pg_timetable-scheduler/)
19+
20+
* [Asynchronous chain execution](https://www.cybertec-postgresql.com/en/pg_timetable-asynchronous-chain-execution/)
21+
22+
* [v4 released](https://www.cybertec-postgresql.com/en/pg_timetable_v4-is-out/)
23+
24+
* [PostgreSQL schedulers: comparison table](https://www.cybertec-postgresql.com/en/postgresql-schedulers-comparison-table/)
25+
26+
## Project feedback
27+
28+
For feature requests or troubleshooting assistance please open an issue on project's [Github page](https://github.com/cybertec-postgresql/pg_timetable).

docs/background.rst

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/basic_jobs.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Getting started
2+
3+
A variety of examples can be found in the [samples](samples.md). If you want to migrate from a different scheduler, you can use scripts from [migration](migration.md) chapter.
4+
5+
## Add simple job
6+
7+
In a real world usually it's enough to use simple jobs. Under this term we understand:
8+
9+
* job is a chain with only one **task** (step) in it;
10+
* it doesn't use complicated logic, but rather simple **command**;
11+
* it doesn't require complex transaction handling, since one task is implicitely executed as a single transaction.
12+
13+
For such a group of chains we've introduced a special function `timetable.add_job()`.
14+
15+
### Function: `timetable.add_job()`
16+
17+
Creates a simple one-task chain
18+
19+
**Returns:** `BIGINT`
20+
21+
#### Parameters
22+
23+
| Parameter | Type | Description | Default |
24+
|-----------|------|-------------|---------|
25+
| `job_name` | `text` | The unique name of the **chain** and **command** | Required |
26+
| `job_schedule` | `timetable.cron` | Time schedule in сron syntax at Postgres server time zone | Required |
27+
| `job_command` | `text` | The SQL which will be executed | Required |
28+
| `job_parameters` | `jsonb` | Arguments for the chain **command** | `NULL` |
29+
| `job_kind` | `timetable.command_kind` | Kind of the command: *SQL*, *PROGRAM* or *BUILTIN* | `SQL` |
30+
| `job_client_name` | `text` | Specifies which client should execute the chain. Set this to `NULL` to allow any client | `NULL` |
31+
| `job_max_instances` | `integer` | The amount of instances that this chain may have running at the same time | `NULL` |
32+
| `job_live` | `boolean` | Control if the chain may be executed once it reaches its schedule | `TRUE` |
33+
| `job_self_destruct` | `boolean` | Self destruct the chain after execution | `FALSE` |
34+
| `job_ignore_errors` | `boolean` | Ignore error during execution | `TRUE` |
35+
| `job_exclusive` | `boolean` | Execute the chain in the exclusive mode | `FALSE` |
36+
37+
**Returns:** the ID of the created chain
38+
39+
## Examples
40+
41+
1. Run `public.my_func()` at 00:05 every day in August Postgres server time zone:
42+
43+
```sql
44+
SELECT timetable.add_job('execute-func', '5 0 * 8 *', 'SELECT public.my_func()');
45+
```
46+
47+
2. Run `VACUUM` at minute 23 past every 2nd hour from 0 through 20 every day Postgres server time zone:
48+
49+
```sql
50+
SELECT timetable.add_job('run-vacuum', '23 0-20/2 * * *', 'VACUUM');
51+
```
52+
53+
3. Refresh materialized view every 2 hours:
54+
55+
```sql
56+
SELECT timetable.add_job('refresh-matview', '@every 2 hours', 'REFRESH MATERIALIZED VIEW public.mat_view');
57+
```
58+
59+
4. Clear log table after **pg_timetable** restart:
60+
61+
```sql
62+
SELECT timetable.add_job('clear-log', '@reboot', 'TRUNCATE timetable.log');
63+
```
64+
65+
5. Reindex at midnight Postgres server time zone on Sundays with [reindexdb](https://www.postgresql.org/docs/current/app-reindexdb.html) utility:
66+
67+
- using default database under default user (no command line arguments)
68+
69+
```sql
70+
SELECT timetable.add_job('reindex', '0 0 * * 7', 'reindexdb', job_kind := 'PROGRAM');
71+
```
72+
73+
- specifying target database and tables, and be verbose
74+
75+
```sql
76+
SELECT timetable.add_job('reindex', '0 0 * * 7', 'reindexdb',
77+
'["--table=foo", "--dbname=postgres", "--verbose"]'::jsonb, 'PROGRAM');
78+
```
79+
80+
- passing password using environment variable through `bash` shell
81+
82+
```sql
83+
SELECT timetable.add_job('reindex', '0 0 * * 7', 'bash',
84+
'["-c", "PGPASSWORD=5m3R7K4754p4m reindexdb -U postgres -h 192.168.0.221 -v"]'::jsonb,
85+
'PROGRAM');
86+
```

0 commit comments

Comments
 (0)