Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions samples/Autonomous.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ END;
$$
LANGUAGE PLPGSQL;

DELETE FROM timetable.chain WHERE chain_name = 'call_proc_every_10s';

WITH
cte_chain (v_chain_id) AS (
INSERT INTO timetable.chain (chain_name, run_at, max_instances, live, self_destruct)
Expand Down
2 changes: 2 additions & 0 deletions samples/Basic.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DELETE FROM timetable.chain WHERE chain_name = 'notify_every_minute';

SELECT timetable.add_job(
job_name => 'notify_every_minute',
job_schedule => '* * * * *',
Expand Down
3 changes: 3 additions & 0 deletions samples/Chain.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ DECLARE
v_task_id bigint;
v_chain_id bigint;
BEGIN
-- Remove existing chain to make this script idempotent
DELETE FROM timetable.chain WHERE chain_name = 'chain_operation';

-- In order to implement chain pperation, we will create a table
CREATE TABLE IF NOT EXISTS timetable.chain_log (
chain_log BIGSERIAL,
Expand Down
2 changes: 2 additions & 0 deletions samples/ClientMessages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ BEGIN
END;
$BODY$;

DELETE FROM timetable.chain WHERE chain_name = 'raise_client_message_every_minute';

SELECT timetable.add_job(
job_name => 'raise_client_message_every_minute',
job_schedule => '* * * * *',
Expand Down
2 changes: 2 additions & 0 deletions samples/CronStyle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ CREATE TABLE IF NOT EXISTS timetable.dummy_log (
-- │ └────────── hour (0 - 23)
-- └──────────── minute (0 - 59)

DELETE FROM timetable.chain WHERE chain_name = 'cron_insert_every_2h_on_27th';

SELECT timetable.add_job (
job_name => 'cron_insert_every_2h_on_27th',
job_schedule => '40 */2 27 * *',
Expand Down
6 changes: 4 additions & 2 deletions samples/DelayedRetry.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ BEGIN
END
$$;

DELETE FROM timetable.chain WHERE chain_name = 'retry_on_fail_delayed';

SELECT timetable.add_job(
job_name => 'retry_on_fail_delayed',
job_schedule => '@every 10 minutes',
Expand All @@ -39,8 +41,8 @@ SELECT timetable.add_job(
job_live => TRUE,
job_ignore_errors => FALSE,
job_on_error => $$SELECT retry_chain_on_error(
worker_name => 'worker001',
worker_name => 'demo_worker',
maximum_retry_count => 3,
minimum_retry_timeout => interval '10 seconds',
maximum_retry_duration => interval '5 minutes')$$
)
);
4 changes: 3 additions & 1 deletion samples/ErrorHandling.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DELETE FROM timetable.chain WHERE chain_name = 'fail_with_on_error_notify';

SELECT timetable.add_job(
job_name => 'fail_with_on_error_notify',
job_schedule => '* * * * *',
Expand All @@ -8,4 +10,4 @@ SELECT timetable.add_job(
job_on_error => $$SELECT pg_notify('monitoring',
format('{"ConfigID": %s, "Message": "Something bad happened"}',
current_setting('pg_timetable.current_chain_id')::bigint))$$
)
);
2 changes: 2 additions & 0 deletions samples/Exclusive.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ BEGIN
END;
$BODY$;

DELETE FROM timetable.chain WHERE chain_name IN ('exclusive_sleep_every_10s', 'exclusive_sleep_after_10s');

SELECT timetable.add_job(
job_name => 'exclusive_sleep_every_10s',
job_schedule => '@every 10 seconds',
Expand Down
2 changes: 2 additions & 0 deletions samples/Log.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DELETE FROM timetable.chain WHERE chain_name = 'builtin_log_every_minute';

SELECT timetable.add_job(
job_name => 'builtin_log_every_minute',
job_schedule => NULL, -- same as '* * * * *'
Expand Down
2 changes: 2 additions & 0 deletions samples/NoOp.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DELETE FROM timetable.chain WHERE chain_name = 'noop_every_minute';

SELECT timetable.add_job(
job_name => 'noop_every_minute',
job_schedule => '* * * * *',
Expand Down
6 changes: 4 additions & 2 deletions samples/SelfDestruct.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
CREATE OR REPLACE FUNCTION raise_func(text)
CREATE OR REPLACE FUNCTION raise_notice_func(text)
RETURNS void LANGUAGE plpgsql AS
$BODY$
BEGIN
RAISE NOTICE '%', $1;
END;
$BODY$;

DELETE FROM timetable.chain WHERE chain_name = 'notify_then_destruct';

SELECT timetable.add_job(
job_name => 'notify_then_destruct',
job_schedule => '* * * * *',
job_command => 'SELECT raise_func($1)',
job_command => 'SELECT raise_notice_func($1)',
job_parameters => '[ "Ahoj from self destruct task" ]' :: jsonb,
job_kind => 'SQL'::timetable.command_kind,
job_live => TRUE,
Expand Down
2 changes: 2 additions & 0 deletions samples/Sleep.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DELETE FROM timetable.chain WHERE chain_name = 'sleep_every_10s';

SELECT timetable.add_job(
job_name => 'sleep_every_10s',
job_schedule => '@every 10 seconds',
Expand Down
Loading