PgQueuer 2.2.0__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/.github/workflows/docs.yml +1 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/AGENTS.md +28 -10
- {pgqueuer-2.2.0/pgqueuer.egg-info → pgqueuer-2.3.0}/PKG-INFO +12 -14
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/README.md +11 -13
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/RELEASE.md +122 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0024-sql-is-assembled-by-the-composer.md +1 -1
- pgqueuer-2.3.0/docs/adr/ADR-0027-sql-statements-are-fixed-text.md +73 -0
- pgqueuer-2.3.0/docs/adr/ADR-0028-persistence-internals-may-change-in-a-minor-release.md +74 -0
- pgqueuer-2.3.0/docs/adr/ADR-0029-a-cancel-request-is-stored-in-the-row.md +74 -0
- pgqueuer-2.3.0/docs/adr/ADR-0030-stale-takeovers-are-counted-and-limited.md +82 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/README.md +69 -9
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/comparisons/celery-comparison.md +4 -12
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/design/README.md +3 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/design/connection-failures.md +4 -4
- pgqueuer-2.3.0/docs/design/dequeue-composition.md +144 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/design/schema-upgrade.md +6 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/design/sql-naming.md +6 -5
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/getting-started/core-concepts.md +16 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/getting-started/installation.md +1 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/getting-started/quickstart.md +6 -13
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/completion-tracking.md +3 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/custom-executors.md +2 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/deferred-execution.md +4 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/deployment.md +6 -7
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/hold-failed-jobs.md +1 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/job-cancellation.md +15 -5
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/performance-tuning.md +1 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/reliability.md +2 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/retry.md +2 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/scheduling.md +7 -5
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/shared-resources.md +4 -9
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/index.md +2 -2
- pgqueuer-2.3.0/docs/integrations/fastapi.md +114 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/integrations/prometheus.md +9 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/integrations/tracing.md +4 -9
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/integrations/web-dashboard.md +1 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/llms.txt +5 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/reference/cli.md +27 -14
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/reference/database-setup.md +4 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/reference/drivers.md +14 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/reference/in-memory.md +1 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/reference/ports-and-adapters.md +1 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/reference/skip-locked.md +1 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/examples/consumer.py +1 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/examples/fastapi_usage.py +12 -21
- pgqueuer-2.3.0/examples/fastapi_worker.py +39 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/examples/flask_sync_usage.py +1 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/examples/producer.py +1 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/examples/scheduler.py +1 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/mkdocs.yml +1 -2
- pgqueuer-2.2.0/docs/agent-guide.md → pgqueuer-2.3.0/pgqueuer/.agents/skills/pgqueuer/SKILL.md +6 -0
- pgqueuer-2.3.0/pgqueuer/__init__.py +55 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/__main__.py +1 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/_version.py +3 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/cli/cli.py +73 -69
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/cli/sql_cmd.py +23 -20
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/drivers/asyncpg.py +1 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/drivers/psycopg.py +33 -28
- pgqueuer-2.3.0/pgqueuer/adapters/inmemory/__init__.py +6 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/inmemory/jobs.py +17 -10
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/inmemory/logs.py +4 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/inmemory/queries.py +12 -7
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/inmemory/schedules.py +4 -10
- pgqueuer-2.3.0/pgqueuer/adapters/persistence/dequeue.py +354 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/persistence/qb.py +105 -73
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/persistence/queries.py +58 -25
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/persistence/query_helpers.py +15 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/persistence/schema_ddl.py +71 -19
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/persistence/schema_inspect.py +14 -8
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/persistence/schema_plan.py +29 -12
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/persistence/sqlstate.py +8 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/tracing/logfire.py +18 -15
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/tracing/opentelemetry.py +27 -16
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/tracing/sentry.py +18 -13
- pgqueuer-2.3.0/pgqueuer/adapters/web/__init__.py +6 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/app.py +3 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/auth.py +9 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/payload.py +3 -5
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/routes.py +40 -32
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/sse.py +2 -5
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/partials/overview.html +1 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/applications.py +1 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/applications.py +1 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/insights.py +11 -11
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/qm.py +47 -19
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/sm.py +3 -3
- pgqueuer-2.3.0/pgqueuer/db.py +13 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/models.py +32 -13
- pgqueuer-2.3.0/pgqueuer/domain/payload.py +28 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/schema/model.py +3 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/schema/queue.py +7 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/schema/queue_log.py +2 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/schema/schedules.py +6 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/schema/statistics.py +5 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/settings.py +12 -4
- pgqueuer-2.3.0/pgqueuer/errors.py +11 -0
- pgqueuer-2.3.0/pgqueuer/executors.py +22 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/factories.py +2 -7
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/metrics/fastapi.py +18 -13
- pgqueuer-2.3.0/pgqueuer/models.py +34 -0
- pgqueuer-2.3.0/pgqueuer/ports/__init__.py +23 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/qm.py +1 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/queries.py +4 -11
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/sm.py +1 -3
- pgqueuer-2.3.0/pgqueuer/types.py +21 -0
- pgqueuer-2.3.0/pgqueuer/web.py +6 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0/pgqueuer.egg-info}/PKG-INFO +12 -14
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer.egg-info/SOURCES.txt +66 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer.egg-info/scm_file_list.json +66 -3
- pgqueuer-2.3.0/pgqueuer.egg-info/scm_version.json +8 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pyproject.toml +5 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/conftest.py +20 -31
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/helpers.py +10 -7
- pgqueuer-2.3.0/test/integration/test_fastapi.py +79 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/integration/test_flask_sync.py +0 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/integration/test_persistence_queries_sql.py +1 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/query_shapes/dequeue_both_gates.sql +23 -22
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/query_shapes/dequeue_entrypoint_gate.sql +23 -22
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/query_shapes/dequeue_global_gate.sql +13 -12
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/query_shapes/dequeue_no_gates.sql +13 -12
- pgqueuer-2.3.0/test/query_shapes/statements/active_workers.sql +11 -0
- pgqueuer-2.3.0/test/query_shapes/statements/aggregate_logs.sql +25 -0
- pgqueuer-2.3.0/test/query_shapes/statements/alter_durability.sql +16 -0
- pgqueuer-2.3.0/test/query_shapes/statements/browse_queue.sql +5 -0
- pgqueuer-2.3.0/test/query_shapes/statements/clear_queue-all.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/clear_queue-entrypoint.sql +8 -0
- pgqueuer-2.3.0/test/query_shapes/statements/clear_queue_log-all.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/clear_queue_log-entrypoint.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/clear_schedule.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/clear_statistics_log-all.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/clear_statistics_log-entrypoint.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/delete_schedule.sql +14 -0
- pgqueuer-2.3.0/test/query_shapes/statements/eligible_queued_work.sql +22 -0
- pgqueuer-2.3.0/test/query_shapes/statements/enqueue-raise.sql +41 -0
- pgqueuer-2.3.0/test/query_shapes/statements/enqueue-skip.sql +43 -0
- pgqueuer-2.3.0/test/query_shapes/statements/enqueue-update_priority.sql +43 -0
- pgqueuer-2.3.0/test/query_shapes/statements/exception_logs.sql +4 -0
- pgqueuer-2.3.0/test/query_shapes/statements/fetch_schedule.sql +30 -0
- pgqueuer-2.3.0/test/query_shapes/statements/has_function.sql +7 -0
- pgqueuer-2.3.0/test/query_shapes/statements/has_table.sql +6 -0
- pgqueuer-2.3.0/test/query_shapes/statements/has_trigger.sql +8 -0
- pgqueuer-2.3.0/test/query_shapes/statements/has_user_defined_enum.sql +3 -0
- pgqueuer-2.3.0/test/query_shapes/statements/insert_schedule.sql +8 -0
- pgqueuer-2.3.0/test/query_shapes/statements/job_duration_percentiles.sql +28 -0
- pgqueuer-2.3.0/test/query_shapes/statements/job_log_history.sql +4 -0
- pgqueuer-2.3.0/test/query_shapes/statements/job_status.sql +4 -0
- pgqueuer-2.3.0/test/query_shapes/statements/list_failed_jobs-asc.sql +4 -0
- pgqueuer-2.3.0/test/query_shapes/statements/list_failed_jobs-desc.sql +4 -0
- pgqueuer-2.3.0/test/query_shapes/statements/log_jobs.sql +55 -0
- pgqueuer-2.3.0/test/query_shapes/statements/log_statistics-all.sql +33 -0
- pgqueuer-2.3.0/test/query_shapes/statements/log_statistics-last.sql +33 -0
- pgqueuer-2.3.0/test/query_shapes/statements/log_statistics-limit.sql +33 -0
- pgqueuer-2.3.0/test/query_shapes/statements/log_statistics-limit_last.sql +33 -0
- pgqueuer-2.3.0/test/query_shapes/statements/mark_job_as_cancelled.sql +55 -0
- pgqueuer-2.3.0/test/query_shapes/statements/next_deferred_eta.sql +11 -0
- pgqueuer-2.3.0/test/query_shapes/statements/next_stale_eta.sql +7 -0
- pgqueuer-2.3.0/test/query_shapes/statements/optimize_autovacuum.sql +33 -0
- pgqueuer-2.3.0/test/query_shapes/statements/optimize_autovacuum_rollback.sql +33 -0
- pgqueuer-2.3.0/test/query_shapes/statements/peek_schedule.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/queue_age.sql +10 -0
- pgqueuer-2.3.0/test/query_shapes/statements/queue_job_by_id.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/queue_log.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/queue_size.sql +9 -0
- pgqueuer-2.3.0/test/query_shapes/statements/queued_work.sql +8 -0
- pgqueuer-2.3.0/test/query_shapes/statements/requeue_jobs.sql +10 -0
- pgqueuer-2.3.0/test/query_shapes/statements/retry_job.sql +15 -0
- pgqueuer-2.3.0/test/query_shapes/statements/schema_info.sql +19 -0
- pgqueuer-2.3.0/test/query_shapes/statements/set_schedule_queued.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/stale_jobs.sql +8 -0
- pgqueuer-2.3.0/test/query_shapes/statements/table_has_column.sql +7 -0
- pgqueuer-2.3.0/test/query_shapes/statements/table_has_index.sql +8 -0
- pgqueuer-2.3.0/test/query_shapes/statements/throughput_summary.sql +36 -0
- pgqueuer-2.3.0/test/query_shapes/statements/throughput_timeseries.sql +37 -0
- pgqueuer-2.3.0/test/query_shapes/statements/unaggregated_log_count.sql +3 -0
- pgqueuer-2.3.0/test/query_shapes/statements/update_heartbeat.sql +1 -0
- pgqueuer-2.3.0/test/query_shapes/statements/update_schedule_heartbeat.sql +1 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_adapter_parity.py +55 -26
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_cancellation.py +70 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_cli_queue.py +21 -5
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_cli_reports.py +23 -21
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_cli_run_and_install.py +34 -14
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_cli_run_options.py +27 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_cli_sql.py +35 -28
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_cli_web.py +5 -5
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_concurrency_limit.py +35 -7
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_connections.py +6 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_dequeue_shapes.py +61 -19
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_docs_agent_guide.py +9 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_drivers.py +4 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_durability.py +58 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_execute_after.py +14 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_factory_supervisor_chain.py +4 -4
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_hold_failed.py +17 -15
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_inmemory.py +117 -3
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_inmemory_integration.py +20 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_insights_service.py +16 -6
- pgqueuer-2.3.0/test/test_log_statistics_shapes.py +20 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_metrics_prometheus.py +49 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_models.py +19 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_psycopg_notify_resilience.py +46 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_qb_upgrade_migration.py +21 -22
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_qm.py +23 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_qm_capacity_poll.py +7 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_qm_default_budget.py +10 -9
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_qm_no_stall.py +16 -11
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_queries.py +101 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_query_plan_regression.py +172 -102
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_retry.py +10 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_run.py +15 -12
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_converge_script.py +41 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_convergence.py +8 -6
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_id_widen.py +8 -9
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_inspect.py +10 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_model.py +10 -8
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_plan.py +27 -7
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_support.py +18 -16
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_settings.py +48 -13
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_sigterm_cancellation.py +14 -9
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_sqlstate.py +23 -18
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_stale_worker_fencing.py +30 -1
- pgqueuer-2.3.0/test/test_statement_snapshots.py +229 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_traceback_record.py +53 -2
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_tracing_graceful_degradation.py +30 -10
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_tracing_opentelemetry.py +40 -8
- pgqueuer-2.3.0/test/test_version.py +48 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_web_routes.py +49 -15
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/windows/test_cli_event_loop_policy.py +1 -1
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/windows/test_psycopg_async_loop.py +8 -11
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/tools/benchmark.py +17 -21
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/tools/dequeue_plan.py +14 -16
- pgqueuer-2.3.0/tools/mkdocs_agent_guide.py +17 -0
- pgqueuer-2.3.0/tools/prometheus/prometheus.py +65 -0
- pgqueuer-2.2.0/docs/design/dequeue-composition.md +0 -89
- pgqueuer-2.2.0/pgqueuer/__init__.py +0 -36
- pgqueuer-2.2.0/pgqueuer/adapters/inmemory/__init__.py +0 -11
- pgqueuer-2.2.0/pgqueuer/adapters/persistence/composer.py +0 -136
- pgqueuer-2.2.0/pgqueuer/adapters/persistence/dequeue.py +0 -538
- pgqueuer-2.2.0/pgqueuer/adapters/web/__init__.py +0 -11
- pgqueuer-2.2.0/pgqueuer/db.py +0 -16
- pgqueuer-2.2.0/pgqueuer/errors.py +0 -19
- pgqueuer-2.2.0/pgqueuer/executors.py +0 -41
- pgqueuer-2.2.0/pgqueuer/models.py +0 -63
- pgqueuer-2.2.0/pgqueuer/ports/__init__.py +0 -36
- pgqueuer-2.2.0/pgqueuer/types.py +0 -39
- pgqueuer-2.2.0/pgqueuer/web.py +0 -11
- pgqueuer-2.2.0/pgqueuer.egg-info/scm_version.json +0 -8
- pgqueuer-2.2.0/test/integration/test_fastapi.py +0 -56
- pgqueuer-2.2.0/test/test_composer.py +0 -176
- pgqueuer-2.2.0/test/test_log_statistics_shapes.py +0 -54
- pgqueuer-2.2.0/tools/mkdocs_agent_guide.py +0 -16
- pgqueuer-2.2.0/tools/prometheus/prometheus.py +0 -126
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/.github/FUNDING.yml +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/.github/pull_request_template.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/.github/workflows/ci.yml +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/.github/workflows/release.yml +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/.gitignore +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/CLAUDE.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/CODE_OF_CONDUCT.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/CONTRIBUTING.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/Dockerfile +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/LICENSE +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docker-compose.yml +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0000-record-each-decision-in-one-short-adr.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0001-job-state-lives-in-postgresql.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0002-workers-claim-by-lock-contention.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0003-notifications-signal-not-carry.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0004-delivery-is-at-least-once.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0005-worker-liveness-is-application-signal.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0016-schema-upgrades-are-computed-from-the-live-database.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0025-the-schema-contract-is-a-declared-manifest.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/adr/ADR-0026-connection-creator-controls-its-lifecycle.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/comparisons/benchmarks.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/design/schema-manifest.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/development/development.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/development/troubleshooting.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/favicon.svg +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/getting-started/upgrading.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/getting-started/when-to-use.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/concurrency-control.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/docker-images.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/guides/heartbeat.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/integrations/postgrest.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/integrations/web-dashboard.png +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/logo.svg +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/reference/architecture.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/reference/database-permissions.md +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/docs/stylesheets/extra.css +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/cli/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/cli/factories.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/cli/supervisor.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/connections.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/drivers/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/inmemory/driver.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/persistence/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/tracing/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/__main__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/deps.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/static/htmx.min.js +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/static/idiomorph-ext.min.js +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/static/sse.js +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/static/style.css +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/base.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/entrypoints.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/failures.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/job_detail.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/jobs.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/overview.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/partials/entrypoints.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/partials/failures.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/partials/jobs_table.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/partials/workers.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/schedules.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/system.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/adapters/web/templates/workers.html +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/buffers.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/completion.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/executors.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/heartbeat.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/listeners.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/logconfig.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/core/tm.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/errors.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/schema/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/schema/declaration.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/schema/notify.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/domain/types.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/metrics/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/metrics/prometheus.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/ports/driver.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/ports/repository.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/ports/tracing.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer/py.typed +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer.egg-info/dependency_links.txt +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer.egg-info/entry_points.txt +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer.egg-info/requires.txt +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/pgqueuer.egg-info/top_level.txt +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/setup.cfg +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/__init__.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v0.18.10.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v0.19.7.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v0.20.1.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v0.22.0.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v0.24.3.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v1.0.2.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v1.1.1.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v1.3.2.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/schema_releases/v1.4.0.sql +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_audit_regressions.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_benchmark_grace_period.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_buffers.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_completion.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_driver_remove_listener.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_executors.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_factories.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_future_guards.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_health_check_cancellation.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_heartbeat.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_helpers.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_issue_536_minimal.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_listener_healthy_contract.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_listeners.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_notification_listener.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_pgqueuer.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_pgqueuer_run_fail_fast.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_port_conformance.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_query_helpers.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_register_entrypoint_validation.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_retry_requeue.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_scheduler.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_scheduler_heartbeat.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_index_rebuild.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_render.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_schema_upgrade.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_slot_contention.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_sql_safety.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_strict_serialized.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_superviser.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_sync_queries.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_tm.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_tracing.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_tracing_logfire.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_tracing_sentry.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_tracing_sentry_status.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_types.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_uvloop.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/test_web_integration.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/test/windows/test_shutdown.py +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/tools/prometheus/Dockerfile +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/tools/web/Dockerfile +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/tools/web/docker-compose.yml +0 -0
- {pgqueuer-2.2.0 → pgqueuer-2.3.0}/uv.lock +0 -0
|
@@ -148,7 +148,7 @@ Files like `pgqueuer/qm.py`, `pgqueuer/queries.py`, `pgqueuer/models.py`, etc. a
|
|
|
148
148
|
|
|
149
149
|
### Deprecation Pattern
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
To deprecate a dataclass field, make its default the only member of an `Enum` class: `class Unset(Enum): TOKEN = auto()`. In `__post_init__`, call `warnings.warn(..., DeprecationWarning, stacklevel=2)` if the value `is not Unset.TOKEN`. Mypy narrows on that check. A module-level `object()` sentinel is a global, so do not use one.
|
|
152
152
|
|
|
153
153
|
### Dependency Injection
|
|
154
154
|
|
|
@@ -267,29 +267,44 @@ comment="""
|
|
|
267
267
|
"""
|
|
268
268
|
```
|
|
269
269
|
|
|
270
|
-
When surrounding indentation would leak into the string, normalize with `textwrap.dedent` (or accept dedent at the consuming end, as `
|
|
270
|
+
When surrounding indentation would leak into the string, normalize with `textwrap.dedent` (or accept dedent at the consuming end, as `block` in `dequeue.py` does for each CTE). Joining *dynamic* parts (`", ".join(items)`) is fine — the rule is about literals.
|
|
271
271
|
|
|
272
272
|
### SQL Style
|
|
273
273
|
|
|
274
|
+
**A statement is fixed text with fixed `$n`.** Keep it in a builder method in `qb.py`. There is no composer (ADR-0027).
|
|
275
|
+
|
|
274
276
|
**No single-letter table or CTE aliases** (`q`, `a`, `p`, `pk`). The SQL here is dense enough already — use the full table/CTE name, or a descriptive alias (`candidate`, `stale`, `job`) when the name is parameterized or shadowed.
|
|
275
277
|
|
|
278
|
+
**Follow the PostgreSQL wiki [Don't Do This](https://wiki.postgresql.org/wiki/Don%27t_Do_This)** in all SQL, DDL, schema declarations, docs snippets, and tooling. Check new or changed SQL against it in review. The rules most likely to bite here: `timestamptz` not `timestamp`; `text` not `varchar(n)`/`char(n)`; identity columns not `serial`; `NOT EXISTS` not `NOT IN`; half-open ranges (`>=` and `<`) not `BETWEEN`; lower-case identifiers. A deliberate departure needs a one-line comment at the site or an ADR (`docs/adr/`). The `bigserial` ids on `queue`, `statistics` and `schedules` are grandfathered; add no more.
|
|
279
|
+
|
|
276
280
|
### `__all__`
|
|
277
281
|
|
|
278
|
-
`__all__
|
|
282
|
+
No module declares `__all__`. To re-export a name, import it as `from x import Name as Name` (PEP 484). Package `__init__.py` files and the top-level backward-compatibility shims do this for each public name. A plain `from x import Name` stays private. Mypy strict and ruff read the `as Name` form as an export. Ruff's PLC0414 calls it a useless alias, so `pyproject.toml` turns that rule off for the re-export modules only.
|
|
279
283
|
|
|
280
284
|
### Module-Level State
|
|
281
285
|
|
|
282
|
-
**No globals
|
|
286
|
+
**No globals.** A module holds only imports, `def`, `class` and type annotations. Type annotations are `TypeAlias`, `Literal` and union aliases, `TypeVar`, `ParamSpec`, `NewType`, and bare annotations without a value. Any other name or statement is a global:
|
|
287
|
+
|
|
288
|
+
- constants of any type, also `UPPER_SNAKE_CASE` `str` and `int`
|
|
289
|
+
- `__all__`, `__version__`, typer apps, `pytestmark` and `HAS_X` import flags
|
|
290
|
+
- calls and other statements that run at import, and the `global` keyword
|
|
283
291
|
|
|
284
|
-
|
|
292
|
+
Two exceptions stay. Add no more:
|
|
285
293
|
|
|
286
|
-
|
|
294
|
+
- `logconfig.logger`, the `pgqueuer` logger, with the line that gives it a `NullHandler`. Other modules log through this logger and add no logger of their own.
|
|
295
|
+
- `tracing.TRACER`, the store of the deprecated `set_tracing_class()`. Both go in the next major release.
|
|
287
296
|
|
|
288
|
-
|
|
289
|
-
- Scalar literal constants (`UPPER_SNAKE_CASE` `int`/`str`/`bytes`/`bool`) and the deprecation `_SENTINEL = object()`.
|
|
290
|
-
- Framework-mandated singletons that hold no mutable state (`app = typer.Typer(...)`).
|
|
297
|
+
An `if TYPE_CHECKING:` guard around imports or defs is fine. Runtime state lives on an instance. To share it, pass it through a constructor or method argument.
|
|
291
298
|
|
|
292
|
-
|
|
299
|
+
Fixes:
|
|
300
|
+
|
|
301
|
+
- A literal with one use: write it at that use.
|
|
302
|
+
- A value with several uses in one module: a parameter default, an attribute or method of the class that owns it, or a small function that returns it.
|
|
303
|
+
- A value that several modules share: a function in the module that owns the concept, or a `StrEnum` for a set of related strings.
|
|
304
|
+
- A lookup dict: `match`/`case` or a function.
|
|
305
|
+
- An optional import: a function with `importlib.util.find_spec`, or a try-import inside the function that needs it.
|
|
306
|
+
- A module attribute that the public API needs, such as `pgqueuer.__version__`: a module-level `def __getattr__` (PEP 562). Put it under `if not TYPE_CHECKING:`, so type checkers still flag unknown names.
|
|
307
|
+
- Test data: inline in the test, a list inside `@pytest.mark.parametrize`, a helper function, or a fixture. Put a mark on each test; do not use `pytestmark`.
|
|
293
308
|
|
|
294
309
|
### Error Handling
|
|
295
310
|
|
|
@@ -356,6 +371,7 @@ If the comment prose in a function is a noticeable fraction of its code, that is
|
|
|
356
371
|
- Fixtures create a **fresh database per test** via `CREATE DATABASE ... TEMPLATE`
|
|
357
372
|
- Key fixtures in `test/conftest.py`: `dsn` (per-test DB URL), `apgdriver` (AsyncpgDriver), `pgdriver` (SyncPsycopgDriver)
|
|
358
373
|
- In-memory tests (`test_inmemory.py`) don't need Postgres
|
|
374
|
+
- The SQL of every `Queries` statement is snapshotted under `test/query_shapes/`; a change regenerates with `PGQUEUER_UPDATE_SNAPSHOTS=1` and is reviewed as a diff.
|
|
359
375
|
|
|
360
376
|
## Versioning
|
|
361
377
|
|
|
@@ -366,6 +382,8 @@ PgQueuer follows **strict semantic versioning** (SemVer) from v1.0.0 onward:
|
|
|
366
382
|
|
|
367
383
|
Never introduce a breaking change in a patch or minor release. If a change would break any public API (function signatures, class fields, import paths, CLI behavior, database schema), it requires a major version bump.
|
|
368
384
|
|
|
385
|
+
Persistence internals may change in a minor release, with a release note (ADR-0028).
|
|
386
|
+
|
|
369
387
|
## Issues and Pull Requests
|
|
370
388
|
|
|
371
389
|
Every issue or pull request an agent writes **must** carry the `Agentic` label ("Issue or PR written mainly by an AI agent. Required on all agent-authored contributions."). See [CONTRIBUTING.md](CONTRIBUTING.md#agentic-contributions).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pgqueuer
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: PostgreSQL-backed background job and task queue for Python.
|
|
5
5
|
Author: JeyBee
|
|
6
6
|
License: MIT License
|
|
@@ -73,6 +73,7 @@ PgQueuer turns PostgreSQL into a fast, reliable background job processor. Jobs l
|
|
|
73
73
|
Already using a coding agent? Copy the onboarding prompt from the
|
|
74
74
|
[PgQueuer documentation](https://janbjorge.github.io/pgqueuer/#let-an-agent-introduce-you).
|
|
75
75
|
The prompt directs your agent to the maintained setup route and canonical docs.
|
|
76
|
+
In your project directory, run `uvx library-skills` to install the PgQueuer guide as an agent skill.
|
|
76
77
|
|
|
77
78
|
## Features
|
|
78
79
|
|
|
@@ -107,7 +108,7 @@ If you already run PostgreSQL, it can do double duty as your job queue. That mea
|
|
|
107
108
|
PgQueuer targets Python 3.11+ and PostgreSQL 14+:
|
|
108
109
|
|
|
109
110
|
```bash
|
|
110
|
-
pip install pgqueuer
|
|
111
|
+
pip install "pgqueuer[asyncpg]"
|
|
111
112
|
pgq install # create tables and functions in your database
|
|
112
113
|
```
|
|
113
114
|
|
|
@@ -119,15 +120,15 @@ PgQueuer pairs **consumers** (workers that process jobs) with **producers** (cod
|
|
|
119
120
|
|
|
120
121
|
### 1. Define a consumer
|
|
121
122
|
|
|
122
|
-
Each entrypoint is a job handler. Run
|
|
123
|
+
Create a file called `myapp.py`. PgQueuer uses a factory pattern: you write an `@asynccontextmanager` function that yields a configured `PgQueuer` instance. Each entrypoint is a job handler. Run the consumer with the CLI: `pgq run myapp:main`.
|
|
123
124
|
|
|
124
125
|
```python
|
|
126
|
+
from contextlib import asynccontextmanager
|
|
125
127
|
import asyncpg
|
|
126
|
-
from pgqueuer import PgQueuer
|
|
127
|
-
from pgqueuer.db import AsyncpgDriver
|
|
128
|
-
from pgqueuer.models import Job
|
|
128
|
+
from pgqueuer import AsyncpgDriver, Job, PgQueuer
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
@asynccontextmanager
|
|
131
|
+
async def main():
|
|
131
132
|
connection = await asyncpg.connect()
|
|
132
133
|
pgq = PgQueuer(AsyncpgDriver(connection))
|
|
133
134
|
|
|
@@ -135,7 +136,7 @@ async def main() -> PgQueuer:
|
|
|
135
136
|
async def process(job: Job) -> None:
|
|
136
137
|
print(f"Processed: {job!r}")
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
yield pgq
|
|
139
140
|
```
|
|
140
141
|
|
|
141
142
|
### 2. Enqueue jobs
|
|
@@ -144,8 +145,7 @@ From your web app, script, or anywhere else with a database connection:
|
|
|
144
145
|
|
|
145
146
|
```python
|
|
146
147
|
import asyncpg
|
|
147
|
-
from pgqueuer
|
|
148
|
-
from pgqueuer.queries import Queries
|
|
148
|
+
from pgqueuer import AsyncpgDriver, Queries
|
|
149
149
|
|
|
150
150
|
async def main() -> None:
|
|
151
151
|
connection = await asyncpg.connect()
|
|
@@ -176,9 +176,7 @@ async with connection.transaction():
|
|
|
176
176
|
|
|
177
177
|
```python
|
|
178
178
|
import asyncio
|
|
179
|
-
from pgqueuer import PgQueuer
|
|
180
|
-
from pgqueuer.models import Job
|
|
181
|
-
from pgqueuer.domain.types import QueueExecutionMode
|
|
179
|
+
from pgqueuer import Job, PgQueuer, QueueExecutionMode
|
|
182
180
|
|
|
183
181
|
async def main() -> None:
|
|
184
182
|
pq = PgQueuer.in_memory()
|
|
@@ -208,7 +206,7 @@ The in-memory adapter has no durability or multi-process coordination, so use th
|
|
|
208
206
|
| [Drivers](docs/reference/drivers.md) | asyncpg, psycopg async/sync: choosing and configuring |
|
|
209
207
|
| [Architecture](docs/reference/architecture.md) | Ports & adapters, `SKIP LOCKED`, design decisions |
|
|
210
208
|
| [Observability](docs/integrations/prometheus.md) | Prometheus metrics, [tracing](docs/integrations/tracing.md), and the dashboard |
|
|
211
|
-
| [Framework integration](examples/) | FastAPI ([example](examples/fastapi_usage.py)) and Flask ([example](examples/flask_sync_usage.py)) |
|
|
209
|
+
| [Framework integration](examples/) | FastAPI ([guide](docs/integrations/fastapi.md), [example](examples/fastapi_usage.py)) and Flask ([example](examples/flask_sync_usage.py)) |
|
|
212
210
|
|
|
213
211
|
## Monitor your queues
|
|
214
212
|
|
|
@@ -13,6 +13,7 @@ PgQueuer turns PostgreSQL into a fast, reliable background job processor. Jobs l
|
|
|
13
13
|
Already using a coding agent? Copy the onboarding prompt from the
|
|
14
14
|
[PgQueuer documentation](https://janbjorge.github.io/pgqueuer/#let-an-agent-introduce-you).
|
|
15
15
|
The prompt directs your agent to the maintained setup route and canonical docs.
|
|
16
|
+
In your project directory, run `uvx library-skills` to install the PgQueuer guide as an agent skill.
|
|
16
17
|
|
|
17
18
|
## Features
|
|
18
19
|
|
|
@@ -47,7 +48,7 @@ If you already run PostgreSQL, it can do double duty as your job queue. That mea
|
|
|
47
48
|
PgQueuer targets Python 3.11+ and PostgreSQL 14+:
|
|
48
49
|
|
|
49
50
|
```bash
|
|
50
|
-
pip install pgqueuer
|
|
51
|
+
pip install "pgqueuer[asyncpg]"
|
|
51
52
|
pgq install # create tables and functions in your database
|
|
52
53
|
```
|
|
53
54
|
|
|
@@ -59,15 +60,15 @@ PgQueuer pairs **consumers** (workers that process jobs) with **producers** (cod
|
|
|
59
60
|
|
|
60
61
|
### 1. Define a consumer
|
|
61
62
|
|
|
62
|
-
Each entrypoint is a job handler. Run
|
|
63
|
+
Create a file called `myapp.py`. PgQueuer uses a factory pattern: you write an `@asynccontextmanager` function that yields a configured `PgQueuer` instance. Each entrypoint is a job handler. Run the consumer with the CLI: `pgq run myapp:main`.
|
|
63
64
|
|
|
64
65
|
```python
|
|
66
|
+
from contextlib import asynccontextmanager
|
|
65
67
|
import asyncpg
|
|
66
|
-
from pgqueuer import PgQueuer
|
|
67
|
-
from pgqueuer.db import AsyncpgDriver
|
|
68
|
-
from pgqueuer.models import Job
|
|
68
|
+
from pgqueuer import AsyncpgDriver, Job, PgQueuer
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
@asynccontextmanager
|
|
71
|
+
async def main():
|
|
71
72
|
connection = await asyncpg.connect()
|
|
72
73
|
pgq = PgQueuer(AsyncpgDriver(connection))
|
|
73
74
|
|
|
@@ -75,7 +76,7 @@ async def main() -> PgQueuer:
|
|
|
75
76
|
async def process(job: Job) -> None:
|
|
76
77
|
print(f"Processed: {job!r}")
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
yield pgq
|
|
79
80
|
```
|
|
80
81
|
|
|
81
82
|
### 2. Enqueue jobs
|
|
@@ -84,8 +85,7 @@ From your web app, script, or anywhere else with a database connection:
|
|
|
84
85
|
|
|
85
86
|
```python
|
|
86
87
|
import asyncpg
|
|
87
|
-
from pgqueuer
|
|
88
|
-
from pgqueuer.queries import Queries
|
|
88
|
+
from pgqueuer import AsyncpgDriver, Queries
|
|
89
89
|
|
|
90
90
|
async def main() -> None:
|
|
91
91
|
connection = await asyncpg.connect()
|
|
@@ -116,9 +116,7 @@ async with connection.transaction():
|
|
|
116
116
|
|
|
117
117
|
```python
|
|
118
118
|
import asyncio
|
|
119
|
-
from pgqueuer import PgQueuer
|
|
120
|
-
from pgqueuer.models import Job
|
|
121
|
-
from pgqueuer.domain.types import QueueExecutionMode
|
|
119
|
+
from pgqueuer import Job, PgQueuer, QueueExecutionMode
|
|
122
120
|
|
|
123
121
|
async def main() -> None:
|
|
124
122
|
pq = PgQueuer.in_memory()
|
|
@@ -148,7 +146,7 @@ The in-memory adapter has no durability or multi-process coordination, so use th
|
|
|
148
146
|
| [Drivers](docs/reference/drivers.md) | asyncpg, psycopg async/sync: choosing and configuring |
|
|
149
147
|
| [Architecture](docs/reference/architecture.md) | Ports & adapters, `SKIP LOCKED`, design decisions |
|
|
150
148
|
| [Observability](docs/integrations/prometheus.md) | Prometheus metrics, [tracing](docs/integrations/tracing.md), and the dashboard |
|
|
151
|
-
| [Framework integration](examples/) | FastAPI ([example](examples/fastapi_usage.py)) and Flask ([example](examples/flask_sync_usage.py)) |
|
|
149
|
+
| [Framework integration](examples/) | FastAPI ([guide](docs/integrations/fastapi.md), [example](examples/fastapi_usage.py)) and Flask ([example](examples/flask_sync_usage.py)) |
|
|
152
150
|
|
|
153
151
|
## Monitor your queues
|
|
154
152
|
|
|
@@ -12,6 +12,128 @@
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
## v2.3.0
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- The single-job form of `enqueue()` on `Queries`, `SyncQueries` and
|
|
20
|
+
`InMemoryQueries` accepts a pydantic model and stores its JSON as bytes.
|
|
21
|
+
`Job.payload_as(Model)` decodes the payload in the handler. It raises
|
|
22
|
+
`ValueError` when the payload is `None` or does not validate. The batch form
|
|
23
|
+
and `QueueRepositoryPort` stay `bytes` (#1239).
|
|
24
|
+
- `pgqueuer` exports the names that the docs import:
|
|
25
|
+
`AbstractEntrypointExecutor`, `CompletionWatcher`, `ConnectionSettings`,
|
|
26
|
+
`Context`, `LogfireTracing`, `OpenTelemetryTracing`, `QueueExecutionMode`,
|
|
27
|
+
`Schedule`, `ScheduleContext`, `SentryTracing`, `SyncPsycopgDriver`,
|
|
28
|
+
`SyncQueries`, `connect_asyncpg`, `create_asyncpg_pool` and
|
|
29
|
+
`create_psycopg_pool`. The old import paths still work (#1235).
|
|
30
|
+
- The wheel ships the agent guide as an agent skill,
|
|
31
|
+
`pgqueuer/.agents/skills/pgqueuer/SKILL.md`. Run `uvx library-skills` in your
|
|
32
|
+
project directory to install it (#1238).
|
|
33
|
+
- Docs: a FastAPI integration guide, with a worker in the app lifespan, and a
|
|
34
|
+
transactional enqueue on a connection from an asyncpg pool (#1236, #1237,
|
|
35
|
+
#1241).
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- A cancel of a picked job is stored in the new column `cancel_requested`. A
|
|
40
|
+
worker that takes over the job after a crash, or after a lost NOTIFY, logs it
|
|
41
|
+
`canceled` and does not run it (#1088). `pgq upgrade` adds the column.
|
|
42
|
+
Workers do not start until it exists.
|
|
43
|
+
- `PsycopgDriver` runs one `add_listener` or `remove_listener` call at a time.
|
|
44
|
+
Before, two adds for a new channel at the same time kept only one callback.
|
|
45
|
+
An add during the removal of the last callback of a channel left the new
|
|
46
|
+
callback without notifications (#1224).
|
|
47
|
+
- `AsyncpgDriver`, `Queries.from_asyncpg_connection` and
|
|
48
|
+
`PgQueuer.from_asyncpg_connection` accept a connection from `pool.acquire()`.
|
|
49
|
+
Before, strict mypy rejected that connection. Only the type hint changes
|
|
50
|
+
(#1240).
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- Within one priority, a dequeue now takes the job that became due first, then
|
|
55
|
+
the lowest id. Before, it took the lowest id, so it read past every job in
|
|
56
|
+
retry backoff (#1132). `pgq upgrade` rebuilds `pgqueuer_ep_prio_id_idx`; the
|
|
57
|
+
build blocks writes to the queue table.
|
|
58
|
+
- Internal: the dequeue text is rendered by `dequeue_sql` and
|
|
59
|
+
`dequeue_limited_sql`. `DequeueSql`, `DequeueShape`, `DequeueArgs`,
|
|
60
|
+
`DequeueCacheKey`, `render_dequeue`, `dequeue_shape`,
|
|
61
|
+
`composer.QueryTemplate` and `composer.TemplateComposer` are removed.
|
|
62
|
+
`QueryQueueBuilder.dequeue_templates` is now `dequeue_texts`. SQL and
|
|
63
|
+
arguments are unchanged.
|
|
64
|
+
- Internal: `QueryQueueBuilder.build_log_statistics_query`, reachable through
|
|
65
|
+
`Queries.qbq`, returns one statement for every filter. Its rows are
|
|
66
|
+
unchanged. `pgqueuer.adapters.persistence.composer` is removed;
|
|
67
|
+
`ComposedQuery` now lives in `query_helpers` and `block` in `dequeue`.
|
|
68
|
+
- Internal: `statement()` writes the final SELECT itself, and `dequeue.FINAL` no longer
|
|
69
|
+
exists. The SQL does not change.
|
|
70
|
+
- Internal: module constants in the in-memory adapter, persistence and schema code become
|
|
71
|
+
functions or the `SqlState` enum: `timestamptz()`, `unique_count_key()`,
|
|
72
|
+
`identifier_pattern()` and `SqlState`. The SQL and DDL do not change.
|
|
73
|
+
- Internal: the web dashboard and `pgqueuer.core.insights` drop their module constants. Use
|
|
74
|
+
`user_env()`, `password_env()`, `page_size()` and `default_stale_threshold()`. Routes and
|
|
75
|
+
responses do not change.
|
|
76
|
+
- Internal: `pgqueuer.adapters.cli.cli.create_app()` builds the `pgq` Typer app, and the
|
|
77
|
+
module attribute `app` no longer exists. Commands and their output do not change.
|
|
78
|
+
- Re-export modules drop `__all__` and re-export each name as `from x import Name as Name`.
|
|
79
|
+
Every public name still imports. `pgqueuer.__version__` still works, but `dir(pgqueuer)` no
|
|
80
|
+
longer lists it. `from pgqueuer import *` now also binds submodule names.
|
|
81
|
+
- Internal: `has_logfire()`, `has_otel()` and `has_sentry()` replace the `HAS_LOGFIRE`,
|
|
82
|
+
`HAS_OTEL` and `HAS_SENTRY` flags. `set_tracing_class()` and `TRACER` stay until the next
|
|
83
|
+
major release.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## v2.2.1
|
|
88
|
+
|
|
89
|
+
### Fixed
|
|
90
|
+
|
|
91
|
+
- `QueueManager` retries a failed poll query. Before, one failed poll stopped
|
|
92
|
+
new work until the last job ended. Three failed polls in a row still end
|
|
93
|
+
the run (#1169).
|
|
94
|
+
- A job error text with a lone surrogate no longer fails the whole log write
|
|
95
|
+
(#1171). `InMemoryQueries` serializes a record before it changes a row, as
|
|
96
|
+
`Queries` does (#1172).
|
|
97
|
+
- Traces show a failed job as an error. Before, OpenTelemetry, Sentry and
|
|
98
|
+
Logfire showed it as OK (#1173).
|
|
99
|
+
- The Prometheus service escapes label values. An entrypoint name with a double
|
|
100
|
+
quote no longer fails the whole scrape (#1174). Its `/health` returns 500
|
|
101
|
+
when the database connection is lost (#1189, #1196).
|
|
102
|
+
- `pgq requeue` says that only failed jobs move (#1177).
|
|
103
|
+
- The dashboard overview shows recent held failures in their own card (#1181).
|
|
104
|
+
- A dequeue without concurrency limits clears the slot that a retried, held or
|
|
105
|
+
requeued job kept. Before, two picked jobs could share a slot (#1182).
|
|
106
|
+
- The in-memory adapter delivers retried and requeued jobs, and new jobs with a
|
|
107
|
+
higher priority. Before, they could stay queued and a drain did not end (#1183).
|
|
108
|
+
- `pgq uninstall` and `pgq verify --expect absent` run the `search_path`
|
|
109
|
+
guard. Before, uninstall could drop tables in a different schema (#1184).
|
|
110
|
+
- Jobs whose headers are not a JSON object run with `headers=None` (#1185,
|
|
111
|
+
#1195). A log row whose traceback is not a JSON object reads with
|
|
112
|
+
`traceback=None` (#1201).
|
|
113
|
+
- `pgq durability` changes one table at a time, so the queue table lock is not
|
|
114
|
+
held while the log table is rewritten (#1186).
|
|
115
|
+
- `pgq upgrade` notes each index it builds on an installed table. That build
|
|
116
|
+
blocks writes to the table (#1187).
|
|
117
|
+
- `pgq sql upgrade` runs a statement only when it changes something, so a rerun
|
|
118
|
+
takes no locks on a current database (#1188).
|
|
119
|
+
- `pgq run --pg-dsn` gives the DSN to user factories through `PGQUEUER_DSN`
|
|
120
|
+
(#1190).
|
|
121
|
+
- A `CancelledError` raised by job code fails the job when no cancel was
|
|
122
|
+
requested. A retry request after a cancel ends the job canceled (#1191).
|
|
123
|
+
- A cancel of many jobs is split into several NOTIFYs, under the PostgreSQL
|
|
124
|
+
payload limit, and logs each job once (#1192).
|
|
125
|
+
- Each cron tick runs once under clock skew and query latency (#1193).
|
|
126
|
+
- Deleting stale schedules no longer keeps every row when the keep list holds a
|
|
127
|
+
NULL (#1199).
|
|
128
|
+
|
|
129
|
+
### Changed
|
|
130
|
+
|
|
131
|
+
- `next_deferred_eta` reads one index entry per entrypoint. It took 17.95 ms
|
|
132
|
+
and now takes 0.30 ms with 100,000 deferred jobs (#1170).
|
|
133
|
+
- The web `/healthz` reads one row by primary key (#1176).
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
15
137
|
## v2.2.0
|
|
16
138
|
|
|
17
139
|
### Added
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# ADR-0027: SQL statements are fixed text
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
Proposed
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
For the SQL that PgQueuer runs, we write each statement as fixed text with
|
|
10
|
+
fixed `$n` placeholders, in a builder method in `qb.py`. Today the dequeue
|
|
11
|
+
statement needs 677 lines and 9 classes for its assembly (ADR-0024). A
|
|
12
|
+
statement with variants comes from one plain function for each variant family.
|
|
13
|
+
We remove the generic composer. The SQL is then easy to find and to read. The
|
|
14
|
+
cost is `$n` numbers that we write by hand. Also, `Queries.log_statistics`
|
|
15
|
+
is slower when the call gives no window.
|
|
16
|
+
|
|
17
|
+
## Context
|
|
18
|
+
|
|
19
|
+
ADR-0024 assembles statements from fragments. It rejected a hand-written
|
|
20
|
+
statement for each shape, because the number of variants doubles with each
|
|
21
|
+
optional fragment. Today the dequeue has four variants. `dequeue.py` and
|
|
22
|
+
`composer.py` in `pgqueuer/adapters/persistence/` assemble them in 677
|
|
23
|
+
lines and 9 classes. A prototype with two plain functions renders the same 84
|
|
24
|
+
texts in 342 lines, with no classes.
|
|
25
|
+
|
|
26
|
+
## Decision
|
|
27
|
+
|
|
28
|
+
A statement is fixed text with fixed `$n` placeholders, in a builder method
|
|
29
|
+
in `qb.py`. A statement with variants comes from one plain function for each
|
|
30
|
+
variant family. The names of database objects come from `DBSettings`, so one
|
|
31
|
+
configuration always gives the same text. PgQueuer has no generic composer.
|
|
32
|
+
|
|
33
|
+
## Consequences
|
|
34
|
+
|
|
35
|
+
Each statement is in one place, and a reviewer reads the SQL that PostgreSQL
|
|
36
|
+
receives. But we write the `$n` numbers by hand, so a change can put them out
|
|
37
|
+
of step with the arguments. The four dequeue texts stay until the worker budget
|
|
38
|
+
leaves the SQL. `Queries.log_statistics` gets one fixed text for every filter.
|
|
39
|
+
When the call gives no window, its median call time over 300 calls increased by
|
|
40
|
+
26.3% and by 36.1% in two single runs. With a window, it decreased by 2.6% and
|
|
41
|
+
by 4.5%.
|
|
42
|
+
|
|
43
|
+
## Alternatives considered
|
|
44
|
+
|
|
45
|
+
We can keep the composer of ADR-0024. We did not choose it, because two plain
|
|
46
|
+
functions give the same texts with less code and no classes.
|
|
47
|
+
|
|
48
|
+
We can use one dequeue statement for all four variants, with neutral values for
|
|
49
|
+
the gates that are not configured. We did not choose it, because it decreased
|
|
50
|
+
the jobs per second by 31.1% with 1 entrypoint and by 8.6% with 20 entrypoints.
|
|
51
|
+
|
|
52
|
+
We can move each statement into the `Queries` method that runs it. We did not
|
|
53
|
+
choose it, because a pilot with six schedule statements removed only 12 lines
|
|
54
|
+
(#1210).
|
|
55
|
+
|
|
56
|
+
## Not covered by this ADR
|
|
57
|
+
|
|
58
|
+
This record does not control the DDL that the schema engine renders (ADR-0016,
|
|
59
|
+
ADR-0025). It does not set which statements get variants and which get one text
|
|
60
|
+
with neutral values. It also does not control the snapshot tests or the driver
|
|
61
|
+
port.
|
|
62
|
+
|
|
63
|
+
## Revisit when
|
|
64
|
+
|
|
65
|
+
Examine this record again if a statement needs more than four variants, the
|
|
66
|
+
number that the dequeue has today.
|
|
67
|
+
|
|
68
|
+
## References
|
|
69
|
+
|
|
70
|
+
[ADR-0000](ADR-0000-record-each-decision-in-one-short-adr.md) gives the rules.
|
|
71
|
+
This record supersedes [ADR-0024](ADR-0024-sql-is-assembled-by-the-composer.md).
|
|
72
|
+
The query builders are in `pgqueuer/adapters/persistence/qb.py`, and the
|
|
73
|
+
dequeue text is in `pgqueuer/adapters/persistence/dequeue.py`.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# ADR-0028: Persistence internals can change in a minor release
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
Proposed
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
"Versioning" in `AGENTS.md` includes import paths and class fields in the
|
|
10
|
+
public API. Because of this, the internals in `pgqueuer/adapters/persistence/`
|
|
11
|
+
can change only in a major release. We let a minor release change these
|
|
12
|
+
persistence internals, with a release note. We do not keep each importable
|
|
13
|
+
name public until v3. The persistence code can then become smaller before
|
|
14
|
+
v3. But user code that imports the persistence internals can break in a
|
|
15
|
+
minor release.
|
|
16
|
+
|
|
17
|
+
## Context
|
|
18
|
+
|
|
19
|
+
"Versioning" has no rule for internal code. But the project already calls
|
|
20
|
+
persistence code internal in two places. The upgrade guide to v1.0 calls
|
|
21
|
+
`pgqueuer.qb` "internal-only". The minor release v1.4.0 changed two builder
|
|
22
|
+
signatures, with the release note "Internal, but reachable via
|
|
23
|
+
`Queries.qbq`". The planned SQL simplification removes more of this code,
|
|
24
|
+
for example `pgqueuer/adapters/persistence/composer.py`. Under "Versioning",
|
|
25
|
+
it must wait for v3.
|
|
26
|
+
|
|
27
|
+
## Decision
|
|
28
|
+
|
|
29
|
+
The persistence internals are the code in `pgqueuer/adapters/persistence/`:
|
|
30
|
+
module names, import paths, classes, fields, methods and functions. They
|
|
31
|
+
include the query builders in `qb.py`, also when a field of a public class
|
|
32
|
+
holds one, such as `Queries.qbq`. A minor release can change the
|
|
33
|
+
persistence internals. Its release note must state each change.
|
|
34
|
+
|
|
35
|
+
Names that `pgqueuer/__init__.py` or a root shim exports stay public, also
|
|
36
|
+
when their code is in `pgqueuer/adapters/persistence/`. Examples are
|
|
37
|
+
`Queries` and `SyncQueries` in `pgqueuer/queries.py`. Their fields stay
|
|
38
|
+
public, but the builders in `qbe`, `qbq` and `qbs` can change.
|
|
39
|
+
|
|
40
|
+
## Consequences
|
|
41
|
+
|
|
42
|
+
The SQL simplification can go into minor releases of v2. User code that
|
|
43
|
+
imports the persistence internals can break in a minor release. Such user
|
|
44
|
+
code is probable, because the upgrade guide to v1.0 tells users of
|
|
45
|
+
`pgqueuer.qb` to use `pgqueuer.adapters.persistence.qb`.
|
|
46
|
+
|
|
47
|
+
## Alternatives considered
|
|
48
|
+
|
|
49
|
+
Each importable name can stay public until a major release, as "Versioning"
|
|
50
|
+
says today. We did not choose it, because the SQL simplification then waits
|
|
51
|
+
for v3.
|
|
52
|
+
|
|
53
|
+
PgQueuer can keep the old code with a deprecation warning until v3. We did
|
|
54
|
+
not choose it, because the old code and the new code then both stay until
|
|
55
|
+
v3.
|
|
56
|
+
|
|
57
|
+
## Not covered by this ADR
|
|
58
|
+
|
|
59
|
+
This record does not control the database schema, the CLI, the protocols in
|
|
60
|
+
`pgqueuer/ports/` or the other adapters. For example, `Queries.qbe.settings`
|
|
61
|
+
stays, because `QueryBuilderEnvironmentPort` in
|
|
62
|
+
`pgqueuer/ports/repository.py` declares it.
|
|
63
|
+
|
|
64
|
+
## Revisit when
|
|
65
|
+
|
|
66
|
+
Examine this record again when the record on strict SemVer merges. That
|
|
67
|
+
record must define the public API. Then put this rule in that record, and
|
|
68
|
+
set the status of this record to `Superseded by ADR-NNNN`.
|
|
69
|
+
|
|
70
|
+
## References
|
|
71
|
+
|
|
72
|
+
[ADR-0000](ADR-0000-record-each-decision-in-one-short-adr.md) gives the rules.
|
|
73
|
+
The v1.4.0 section of `RELEASE.md` has the note on the builders. Section 8
|
|
74
|
+
of `docs/getting-started/upgrading.md` lists the internal modules of v1.0.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# ADR-0029: A cancel request for a picked job is stored in its row
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
Proposed
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
`mark_job_as_cancelled` keeps a `picked` row, so the job keeps its slot and
|
|
10
|
+
its dedupe key while the handler runs. The request itself goes only into a
|
|
11
|
+
NOTIFY. When the worker of the job is dead, or its listener is down, the NOTIFY
|
|
12
|
+
is lost, and stale recovery runs the job again. We store the request in the
|
|
13
|
+
row, in a new nullable column. A worker that claims a row with a request logs
|
|
14
|
+
the job `canceled` and does not run the handler. We do not keep the NOTIFY as
|
|
15
|
+
the only record. The cost is one column and one `pgq upgrade`.
|
|
16
|
+
|
|
17
|
+
## Context
|
|
18
|
+
|
|
19
|
+
`build_log_job_query` in `pgqueuer/adapters/persistence/qb.py` removes the
|
|
20
|
+
`queued` and `failed` rows of a cancel and keeps the `picked` rows. The
|
|
21
|
+
NOTIFY asks the worker that holds the job to stop it (ADR-0003). A worker that
|
|
22
|
+
does not listen at that time does not get the NOTIFY. A `picked` row whose
|
|
23
|
+
heartbeat stops becomes claimable again (ADR-0005). The next worker does not
|
|
24
|
+
know about the cancel, and runs the job to its end. A retry that the handler
|
|
25
|
+
writes after the cancel puts the row back to `queued`, with the same result.
|
|
26
|
+
|
|
27
|
+
## Decision
|
|
28
|
+
|
|
29
|
+
The queue table gets the nullable column `cancel_requested timestamptz`.
|
|
30
|
+
`mark_job_as_cancelled` sets it to `NOW()` on `picked` rows, in the same
|
|
31
|
+
statement that removes the `queued` and `failed` rows. A retry does not
|
|
32
|
+
clear the column.
|
|
33
|
+
|
|
34
|
+
Before a worker runs a handler, it reads the column of the claimed job. When
|
|
35
|
+
the column has a value, the worker logs the job `canceled` and does not run
|
|
36
|
+
the handler. This check covers each claim: a new job, a stale takeover and a
|
|
37
|
+
retried job. The NOTIFY stays, because it stops a handler that runs.
|
|
38
|
+
|
|
39
|
+
## Consequences
|
|
40
|
+
|
|
41
|
+
A cancelled job does not start again, also when its worker died or did not get
|
|
42
|
+
the NOTIFY. The log shows `canceled`. `Job` gets the field
|
|
43
|
+
`cancel_requested`. The schema changes, so users run `pgq upgrade` before
|
|
44
|
+
new workers start. A handler that runs on a live worker with a dead listener
|
|
45
|
+
still runs to its end.
|
|
46
|
+
|
|
47
|
+
## Alternatives considered
|
|
48
|
+
|
|
49
|
+
We can keep the NOTIFY as the only record. This adds nothing. We did not choose
|
|
50
|
+
it, because a lost NOTIFY then runs a cancelled job again.
|
|
51
|
+
|
|
52
|
+
We can add the status `cancelling`. We did not choose it, because the claim,
|
|
53
|
+
the slot index and the dedupe index read `picked`, and each of them then needs
|
|
54
|
+
a change.
|
|
55
|
+
|
|
56
|
+
We can delete a stale row with a request in the dequeue statement, and log it
|
|
57
|
+
there. We did not choose it, because each dequeue text then gets one more
|
|
58
|
+
write, and a retried row with a request still runs.
|
|
59
|
+
|
|
60
|
+
## Not covered by this ADR
|
|
61
|
+
|
|
62
|
+
This record does not control how often a running handler reads the column, for
|
|
63
|
+
example at each heartbeat. It does not control the NOTIFY payload (ADR-0003).
|
|
64
|
+
|
|
65
|
+
## Revisit when
|
|
66
|
+
|
|
67
|
+
Examine this record again when a running handler must stop without a NOTIFY,
|
|
68
|
+
for example when the listener of its worker is down.
|
|
69
|
+
|
|
70
|
+
## References
|
|
71
|
+
|
|
72
|
+
[ADR-0000](ADR-0000-record-each-decision-in-one-short-adr.md) gives the rules.
|
|
73
|
+
`mark_job_as_cancelled` is in `pgqueuer/adapters/persistence/queries.py`.
|
|
74
|
+
Stale recovery is `next_stale` in `pgqueuer/adapters/persistence/dequeue.py`.
|