Skip to content

Commit 82b02b7

Browse files
authored
Merge pull request #4 from tavallaie/main
Transfer `pgmq` package ownership and fix delayed message bug
2 parents 996f143 + 93597eb commit 82b02b7

File tree

17 files changed

+261
-255
lines changed

17 files changed

+261
-255
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
Install with `pip` from pypi.org:
66

77
```bash
8-
pip install pgmq-py
8+
pip install pgmq
99
```
1010

1111
To use the async version, install with the optional dependencies:
1212

1313
```bash
14-
pip install pgmq-py[async]
14+
pip install pgmq[async]
1515
```
1616

1717
Dependencies:
@@ -41,7 +41,7 @@ export PG_DATABASE=test_db
4141
Initialize a connection to Postgres using environment variables:
4242

4343
```python
44-
from pgmq_py import PGMQueue, Message
44+
from pgmq import PGMQueue, Message
4545

4646
queue = PGMQueue()
4747
```
@@ -51,7 +51,7 @@ queue = PGMQueue()
5151
Initialization for the async version requires an explicit call of the initializer:
5252

5353
```python
54-
from pgmq_py.async_queue import PGMQueue
54+
from pgmq.async_queue import PGMQueue
5555

5656
async def main():
5757
queue = PGMQueue()
@@ -63,7 +63,7 @@ Then, the interface is exactly the same as the sync version.
6363
### Initialize a connection to Postgres without environment variables
6464

6565
```python
66-
from pgmq_py import PGMQueue, Message
66+
from pgmq import PGMQueue, Message
6767

6868
queue = PGMQueue(
6969
host="0.0.0.0",
@@ -260,13 +260,13 @@ queue = PGMQueue(
260260

261261
# Using Transactions
262262

263-
To perform multiple operations within a single transaction, use the `@transaction` decorator from the `pgmq_py.decorators` module.
263+
To perform multiple operations within a single transaction, use the `@transaction` decorator from the `pgmq.decorators` module.
264264
This ensures that all operations within the function are executed within the same transaction and are either committed together or rolled back if an error occurs.
265265

266266
First, import the transaction decorator:
267267

268268
```python
269-
from pgmq_py.decorators import transaction
269+
from pgmq.decorators import transaction
270270
```
271271

272272
### Example: Transactional Operation

benches/bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Optional
77
import pandas as pd
88
from sqlalchemy import create_engine, text
9-
from pgmq_py import PGMQueue
9+
from pgmq import PGMQueue
1010
from urllib.parse import urlparse
1111
import typer
1212
from benches.ops import consume, produce, queue_depth

benches/locustfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import time
2-
from pgmq_py import PGMQueue
2+
from pgmq import PGMQueue
33
from locust import task, User
44

55

benches/ops.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22
import logging
3-
import multiprocessing
43
import os
54
import time
65
import psycopg
@@ -183,7 +182,7 @@ def consume(
183182
def queue_depth(
184183
queue_name: str,
185184
connection_info: dict,
186-
kill_flag: multiprocessing.Value,
185+
kill_flag,
187186
duration_seconds: int,
188187
):
189188
username = connection_info["username"]

benches/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from sqlalchemy import create_engine, text
88
import numpy as np
99
from benches.log import write_event_log
10-
from pgmq_py import PGMQueue
10+
from pgmq import PGMQueue
1111

1212

1313
def stack_events(

example/example_app_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
2-
from pgmq_py.async_queue import PGMQueue
3-
from pgmq_py.decorators import async_transaction as transaction
2+
from pgmq.async_queue import PGMQueue
3+
from pgmq.decorators import async_transaction as transaction
44

55

66
async def main():

example/example_app_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from pgmq_py.queue import PGMQueue
2-
from pgmq_py.decorators import transaction
1+
from pgmq.queue import PGMQueue
2+
from pgmq.decorators import transaction
33

44
queue = PGMQueue(
55
host="localhost",

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
2-
name = "pgmq-py"
3-
version = "0.1.0"
2+
name = "pgmq"
3+
version = "1.0.0"
44
description = "Python client for the PGMQ Postgres extension."
55
readme = "README.md"
66
license = "Apache-2.0"

src/pgmq/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from pgmq.queue import Message, PGMQueue # type: ignore
2+
from pgmq.decorators import transaction, async_transaction
3+
4+
__all__ = ["Message", "PGMQueue", "transaction", "async_transaction"]

src/pgmq_py/async_queue.py renamed to src/pgmq/async_queue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
from orjson import dumps, loads
1111

12-
from pgmq_py.messages import Message, QueueMetrics
13-
from pgmq_py.decorators import async_transaction as transaction
12+
from pgmq.messages import Message, QueueMetrics
13+
from pgmq.decorators import async_transaction as transaction
1414

1515

1616
@dataclass

0 commit comments

Comments
 (0)