Module: PGMQ::Client::Maintenance
- Included in:
- PGMQ::Client
- Defined in:
- lib/pgmq/client/maintenance.rb
Overview
Queue maintenance operations
This module handles queue maintenance tasks such as purging messages and detaching archive tables.
Instance Method Summary collapse
-
#disable_notify_insert(queue_name) ⇒ void
Disables PostgreSQL NOTIFY for a queue.
-
#enable_notify_insert(queue_name, throttle_interval_ms: 250) ⇒ void
Enables PostgreSQL NOTIFY when messages are inserted into a queue.
-
#purge_queue(queue_name) ⇒ Integer
Purges all messages from a queue.
Instance Method Details
#disable_notify_insert(queue_name) ⇒ void
This method returns an undefined value.
Disables PostgreSQL NOTIFY for a queue
66 67 68 69 70 71 72 73 74 |
# File 'lib/pgmq/client/maintenance.rb', line 66 def disable_notify_insert(queue_name) validate_queue_name!(queue_name) with_connection do |conn| conn.exec_params("SELECT pgmq.disable_notify_insert($1::text)", [queue_name]) end nil end |
#enable_notify_insert(queue_name, throttle_interval_ms: 250) ⇒ void
This method returns an undefined value.
Enables PostgreSQL NOTIFY when messages are inserted into a queue
When enabled, PostgreSQL will send a NOTIFY event on message insert, allowing clients to use LISTEN instead of polling. The throttle interval prevents notification storms during high-volume inserts.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pgmq/client/maintenance.rb', line 46 def enable_notify_insert(queue_name, throttle_interval_ms: 250) validate_queue_name!(queue_name) with_connection do |conn| conn.exec_params( "SELECT pgmq.enable_notify_insert($1::text, $2::integer)", [queue_name, throttle_interval_ms] ) end nil end |
#purge_queue(queue_name) ⇒ Integer
Purges all messages from a queue
18 19 20 21 22 23 24 25 26 |
# File 'lib/pgmq/client/maintenance.rb', line 18 def purge_queue(queue_name) validate_queue_name!(queue_name) result = with_connection do |conn| conn.exec_params("SELECT pgmq.purge_queue($1::text)", [queue_name]) end result[0]["purge_queue"] end |