Skip to content

Conversation

Copy link

Copilot AI commented Nov 1, 2025

Implements four missing PGMQ features: time-based partition support, archive table operations, and visibility timeout updates.

Changes

Time-based Partitioning

  • create_partitioned_queue() now accepts Union[int, str] for intervals
  • Numeric intervals (e.g., 10000) partition by msg_id
  • Time-based intervals (e.g., '1 day', '7 days') partition by enqueued_at
  • Added _validate_partition_interval() with regex validation for PostgreSQL interval syntax
# Numeric partitioning (existing)
pgmq.create_partitioned_queue('queue1', partition_interval=10000, retention_interval=100000)

# Time-based partitioning (new)
pgmq.create_partitioned_queue('queue2', partition_interval='1 day', retention_interval='7 days')

Archive Operations

  • read_archive(queue_name) - read single message from pgmq.a_<queue_name>
  • read_archive_batch(queue_name, batch_size) - read multiple messages
  • detach_archive(queue_name) - detach archive table from queue using pgmq.detach_archive()
  • All methods support sync/async, with queue name validation before SQL execution

Visibility Timeout Updates

  • set_vt(queue_name, msg_id, vt) - update message visibility timeout via pgmq.set_vt()
  • Returns updated Message object or None

Testing

Added 366 tests covering all methods across multiple database drivers (pg8000, psycopg2, psycopg, psycopg2cffi, asyncpg) in both sync and async modes, including validation and error cases.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • install.python-poetry.org
    • Triggering command: curl -sSL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt
  1. Add time-based partition option and validation to create_partitioned_queue method.
  2. Read(single/batch) Archive Table ( read_archive method )
  3. Detach Archive Table ( detach_archive method )
  4. Add set_vt utils method.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits November 1, 2025 13:37
…tion support

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
…revention

Co-authored-by: jason810496 <68415893+jason810496@users.noreply.github.com>
Copilot AI changed the title [WIP] Add time-based partition option and validation to create_partitioned_queue Add time-based partitioning, archive operations, and set_vt method Nov 1, 2025
Copilot AI requested a review from jason810496 November 1, 2025 13:52
Copilot finished work on behalf of jason810496 November 1, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants