You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pgmq_sqlalchemy/queue.py
+33-16Lines changed: 33 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ def __init__(
77
77
78
78
.. note::
79
79
| ``PGMQueue`` will **auto create** the ``pgmq`` extension ( and ``pg_partman`` extension if the method is related with **partitioned_queue** ) if it does not exist in the Postgres.
80
-
| But you must make sure that the ``pgmq`` extension ( or ``pg_partman`` extension )already **installed** in the Postgres.
80
+
| But you must make sure that the ``pgmq`` extension ( or ``pg_partman`` extension )already **installed** in the Postgres.
81
81
"""
82
82
ifnotdsnandnotengineandnotsession_maker:
83
83
raiseValueError("Must provide either dsn, engine, or session_maker")
|schema_message_class|_ or ``None`` if the queue is empty.
529
+
524
530
.. note::
525
531
| ``PGMQ`` use |for_update_skip_locked|_ lock to make sure **a message is only read by one consumer**.
526
532
| See the `pgmq.read <https://github.com/tembo-io/pgmq/blob/main/pgmq-extension/sql/pgmq.sql?plain=1#L44-L75>`_ function for more details.
527
533
|
528
-
| For **consumer retries mechanism** (e.g. mark a message as failed after a certain number of retries) can be implemented by using the ``read_ct`` field in the ``Message`` object.
534
+
| For **consumer retries mechanism** (e.g. mark a message as failed after a certain number of retries) can be implemented by using the ``read_ct`` field in the |schema_message_class|_ object.
529
535
530
536
531
537
.. important::
@@ -642,6 +648,9 @@ def read_batch(
642
648
| Read a batch of messages from the queue.
643
649
| Usage:
644
650
651
+
Returns:
652
+
List of |schema_message_class|_ or ``None`` if the queue is empty.
653
+
645
654
.. code-block:: python
646
655
647
656
from pgmq_sqlalchemy.schema import Message
@@ -752,6 +761,9 @@ def read_with_poll(
752
761
max_poll_seconds (int): The maximum number of seconds to poll.
753
762
poll_interval_ms (int): The interval in milliseconds to poll.
754
763
764
+
Returns:
765
+
List of |schema_message_class|_ or ``None`` if the queue is empty.
| You should use a **distributed lock** to avoid **race conditions** when calling :py:meth:`~pgmq_sqlalchemy.metrics_call` in **concurrent** |drop_queue_method|_ **scenarios**.
1197
+
| You should use a **distributed lock** to avoid **race conditions** when calling |metrics_all_method|_ in **concurrent** |drop_queue_method|_ **scenarios**.
1182
1198
|
1183
1199
| Since the default PostgreSQL isolation level is |read_committed_isolation_level|_, the queue metrics to be fetched **may not exist** if there are **concurrent** |drop_queue_method|_ **operations**.
1200
+
| Check the `pgmq.metrics_all <https://github.com/tembo-io/pgmq/blob/main/pgmq-extension/sql/pgmq.sql?plain=1#L334-L346>`_ function for more details.
0 commit comments