Internal Functions | |
Low-level event handling | |
pgq. | Creates SELECT statement that fetches events for this batch. |
pgq. | Returns set of table names where this batch events may reside. |
pgq. | Allows full control over what goes to retry queue. |
pgq. | Helper function for pgq.next_batch_custom() to do extended tick search. |
Ticker | |
pgq. | External ticker: Insert a tick with a particular tick_id and timestamp. |
pgq. | Check if tick is needed for the queue and insert it. |
pgq. | Creates ticks for all unpaused queues which dont have external ticker. |
Periodic maintenence | |
pgq. | Moves retry events back to main queue. |
pgq. | Rotate tables for one queue. |
pgq. | Stores the txid when the rotation was visible. |
pgq. | Returns list of tablenames that need frequent vacuuming. |
pgq. | Returns list of functions to call for maintenance. |
Random utility functions | |
pgq. | Make event tables readable by public. |
pgq. | Copy grants from one table to another. |
pgq. | Tunes storage settings for queue data tables |
pgq. | Simulate lots of events happening to force ticker to tick. |
pgq. | Read current last_val from seq, without affecting it. |
pgq. | Like setval() but does not allow going back. |
pgq. | Quete fully-qualified object name for SQL. |
pgq.event_retry_raw( x_queue text, x_consumer text, x_retry_after timestamptz, x_ev_id bigint, x_ev_time timestamptz, x_ev_retry integer, x_ev_type text, x_ev_data text, x_ev_extra1 text, x_ev_extra2 text, x_ev_extra3 text, x_ev_extra4 text ) returns bigint
Allows full control over what goes to retry queue.
x_queue | name of the queue |
x_consumer | name of the consumer |
x_retry_after | when the event should be processed again |
x_ev_id | event id |
x_ev_time | creation time |
x_ev_retry | retry count |
x_ev_type | user data |
x_ev_data | user data |
x_ev_extra1 | user data |
x_ev_extra2 | user data |
x_ev_extra3 | user data |
x_ev_extra4 | user data |
Event ID.
pgq.find_tick_helper( in i_queue_id int4, in i_prev_tick_id int8, in i_prev_tick_time timestamptz, in i_prev_tick_seq int8, in i_min_count int8, in i_min_interval interval, out next_tick_id int8, out next_tick_time timestamptz, out next_tick_seq int8 ) as
Helper function for pgq.next_batch_custom() to do extended tick search.
pgq.maint_operations( out func_name text, out func_arg text ) returns setof record
Returns list of functions to call for maintenance.
The goal is to avoid hardcoding them into maintenance process.
Function should take either 1 or 0 arguments and return 1 if it wants to be called immediately again, 0 if not.
func_name | Function to call |
func_arg | Optional argument to function (queue name) |
pgq.force_tick( i_queue_name text ) returns bigint
Simulate lots of events happening to force ticker to tick.
Should be called in loop, with some delay until last tick changes or too much time is passed.
Such function is needed because paraller calls of pgq.ticker() are dangerous, and cannot be protected with locks as snapshot is taken before locking.
i_queue_name | Name of the queue |
Currently last tick id.
Creates SELECT statement that fetches events for this batch.
pgq.batch_event_sql( x_batch_id bigint ) returns text
Returns set of table names where this batch events may reside.
pgq.batch_event_tables( x_batch_id bigint ) returns setof text
Allows full control over what goes to retry queue.
pgq.event_retry_raw( x_queue text, x_consumer text, x_retry_after timestamptz, x_ev_id bigint, x_ev_time timestamptz, x_ev_retry integer, x_ev_type text, x_ev_data text, x_ev_extra1 text, x_ev_extra2 text, x_ev_extra3 text, x_ev_extra4 text ) returns bigint
Helper function for pgq.next_batch_custom() to do extended tick search.
pgq.find_tick_helper( in i_queue_id int4, in i_prev_tick_id int8, in i_prev_tick_time timestamptz, in i_prev_tick_seq int8, in i_min_count int8, in i_min_interval interval, out next_tick_id int8, out next_tick_time timestamptz, out next_tick_seq int8 ) as
External ticker: Insert a tick with a particular tick_id and timestamp.
pgq.ticker( i_queue_name text, i_tick_id bigint, i_orig_timestamp timestamptz, i_event_seq bigint ) returns bigint
Check if tick is needed for the queue and insert it.
pgq.ticker( i_queue_name text ) returns bigint
Creates ticks for all unpaused queues which dont have external ticker.
pgq.ticker() returns bigint
Moves retry events back to main queue.
pgq.maint_retry_events() returns integer
Rotate tables for one queue.
pgq.maint_rotate_tables_step1( i_queue_name text ) returns integer
Stores the txid when the rotation was visible.
pgq.maint_rotate_tables_step2() returns integer
Returns list of tablenames that need frequent vacuuming.
pgq.maint_tables_to_vacuum() returns setof text
Returns list of functions to call for maintenance.
pgq.maint_operations( out func_name text, out func_arg text ) returns setof record
Make event tables readable by public.
pgq.grant_perms( x_queue_name text ) returns integer
Tunes storage settings for queue data tables
pgq.tune_storage( i_queue_name text ) returns integer
Simulate lots of events happening to force ticker to tick.
pgq.force_tick( i_queue_name text ) returns bigint
Read current last_val from seq, without affecting it.
pgq.seq_getval( i_seq_name text ) returns bigint
Like setval() but does not allow going back.
pgq.seq_setval( i_seq_name text, i_new_value int8 ) returns bigint
Quete fully-qualified object name for SQL.
pgq.quote_fqname( i_name text ) returns text