Comparing version 10.1.2 to 10.1.3
{ | ||
"name": "pg-boss", | ||
"version": "10.1.2", | ||
"version": "10.1.3", | ||
"description": "Queueing jobs in Postgres from Node.js like a boss", | ||
@@ -10,12 +10,12 @@ "main": "./src/index.js", | ||
"dependencies": { | ||
"cron-parser": "^4.0.0", | ||
"pg": "^8.5.1", | ||
"cron-parser": "^4.9.0", | ||
"pg": "^8.12.0", | ||
"serialize-error": "^8.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.3.3", | ||
"luxon": "^3.0.1", | ||
"mocha": "^10.0.0", | ||
"@types/node": "^20.16.5", | ||
"luxon": "^3.5.0", | ||
"mocha": "^10.7.3", | ||
"nyc": "^17.0.0", | ||
"standard": "^17.0.0" | ||
"standard": "^17.1.2" | ||
}, | ||
@@ -22,0 +22,0 @@ "scripts": { |
126
src/plans.js
@@ -197,3 +197,3 @@ const DEFAULT_SCHEMA = 'pgboss' | ||
dead_letter text, | ||
policy text | ||
policy text | ||
) PARTITION BY LIST (name) | ||
@@ -559,13 +559,44 @@ ` | ||
return ` | ||
WITH results AS ( | ||
UPDATE ${schema}.job SET | ||
state = CASE | ||
WITH deleted_jobs AS ( | ||
DELETE FROM ${schema}.job | ||
WHERE ${where} | ||
RETURNING * | ||
), | ||
retried_jobs AS ( | ||
INSERT INTO ${schema}.job ( | ||
id, | ||
name, | ||
priority, | ||
data, | ||
state, | ||
retry_limit, | ||
retry_count, | ||
retry_delay, | ||
retry_backoff, | ||
start_after, | ||
started_on, | ||
singleton_key, | ||
singleton_on, | ||
expire_in, | ||
created_on, | ||
completed_on, | ||
keep_until, | ||
dead_letter, | ||
policy, | ||
output | ||
) | ||
SELECT | ||
id, | ||
name, | ||
priority, | ||
data, | ||
CASE | ||
WHEN retry_count < retry_limit THEN '${JOB_STATES.retry}'::${schema}.job_state | ||
ELSE '${JOB_STATES.failed}'::${schema}.job_state | ||
END, | ||
completed_on = CASE | ||
WHEN retry_count < retry_limit THEN NULL | ||
ELSE now() | ||
END, | ||
start_after = CASE | ||
END as state, | ||
retry_limit, | ||
retry_count, | ||
retry_delay, | ||
retry_backoff, | ||
CASE | ||
WHEN retry_count = retry_limit THEN start_after | ||
@@ -577,7 +608,74 @@ WHEN NOT retry_backoff THEN now() + retry_delay * interval '1' | ||
) * interval '1' | ||
END, | ||
output = ${output} | ||
WHERE ${where} | ||
END as start_after, | ||
started_on, | ||
singleton_key, | ||
singleton_on, | ||
expire_in, | ||
created_on, | ||
CASE | ||
WHEN retry_count < retry_limit THEN NULL | ||
ELSE now() | ||
END as completed_on, | ||
keep_until, | ||
dead_letter, | ||
policy, | ||
${output} | ||
FROM deleted_jobs | ||
ON CONFLICT DO NOTHING | ||
RETURNING * | ||
), dlq_jobs as ( | ||
), | ||
failed_jobs as ( | ||
INSERT INTO ${schema}.job ( | ||
id, | ||
name, | ||
priority, | ||
data, | ||
state, | ||
retry_limit, | ||
retry_count, | ||
retry_delay, | ||
retry_backoff, | ||
start_after, | ||
started_on, | ||
singleton_key, | ||
singleton_on, | ||
expire_in, | ||
created_on, | ||
completed_on, | ||
keep_until, | ||
dead_letter, | ||
policy, | ||
output | ||
) | ||
SELECT | ||
id, | ||
name, | ||
priority, | ||
data, | ||
'${JOB_STATES.failed}'::${schema}.job_state as state, | ||
retry_limit, | ||
retry_count, | ||
retry_delay, | ||
retry_backoff, | ||
start_after, | ||
started_on, | ||
singleton_key, | ||
singleton_on, | ||
expire_in, | ||
created_on, | ||
now() as completed_on, | ||
keep_until, | ||
dead_letter, | ||
policy, | ||
${output} | ||
FROM deleted_jobs | ||
WHERE id NOT IN (SELECT id from retried_jobs) | ||
RETURNING * | ||
), | ||
results as ( | ||
SELECT * FROM retried_jobs | ||
UNION ALL | ||
SELECT * FROM failed_jobs | ||
), | ||
dlq_jobs as ( | ||
INSERT INTO ${schema}.job (name, data, output, retry_limit, keep_until) | ||
@@ -584,0 +682,0 @@ SELECT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99191
2736
Updatedcron-parser@^4.9.0
Updatedpg@^8.12.0