weenspace-queue 0.1.1__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/PKG-INFO +9 -5
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/README.md +8 -4
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/pyproject.toml +1 -1
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/weenspace_queue/__init__.py +18 -2
- weenspace_queue-0.1.3/weenspace_queue/asyncio/__init__.py +23 -0
- weenspace_queue-0.1.3/weenspace_queue/asyncio/publisher.py +3 -0
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/weenspace_queue/asyncio/rabbitmq_async.py +4 -4
- weenspace_queue-0.1.3/weenspace_queue/connection.py +3 -0
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/weenspace_queue/constants.py +2 -2
- weenspace_queue-0.1.3/weenspace_queue/entities.py +3 -0
- weenspace_queue-0.1.3/weenspace_queue/exceptions.py +3 -0
- weenspace_queue-0.1.3/weenspace_queue/providers/__init__.py +15 -0
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/weenspace_queue/providers/rabbitmq.py +4 -4
- weenspace_queue-0.1.3/weenspace_queue/qpid/__init__.py +1 -0
- weenspace_queue-0.1.3/weenspace_queue/qpid/proton/__init__.py +3 -0
- weenspace_queue-0.1.3/weenspace_queue/ssl_configuration.py +3 -0
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/weenspace_queue/utils.py +8 -0
- weenspace_queue-0.1.1/weenspace_queue/asyncio/__init__.py +0 -4
- weenspace_queue-0.1.1/weenspace_queue/providers/__init__.py +0 -4
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/LICENSE +0 -0
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/weenspace_queue/asyncio/aws_async.py +0 -0
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/weenspace_queue/base.py +0 -0
- {weenspace_queue-0.1.1 → weenspace_queue-0.1.3}/weenspace_queue/providers/aws.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: weenspace-queue
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: WeenSpace queue client for RabbitMQ and AWS SQS, supporting both synchronous and asynchronous operations.
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -58,7 +58,7 @@ pip install weenspace-queue
|
|
|
58
58
|
```python
|
|
59
59
|
from weenspace_queue import Message, QueueClient, QueueSpecification
|
|
60
60
|
|
|
61
|
-
client = QueueClient("
|
|
61
|
+
client = QueueClient("RABBITMQ", uri="amqp://guest:guest@localhost:5672/")
|
|
62
62
|
queue = client.declare_queue(QueueSpecification(name="my-queue"))
|
|
63
63
|
client.publish(queue, Message(body=b"Hello WeenSpace!"))
|
|
64
64
|
|
|
@@ -71,6 +71,10 @@ client.consume(queue, handler=on_message, prefetch=10)
|
|
|
71
71
|
|
|
72
72
|
Install AWS support with `pip install "weenspace-queue[aws]"`.
|
|
73
73
|
|
|
74
|
+
### AWS SQS and SNS
|
|
75
|
+
|
|
76
|
+
See [examples/aws/sqs.py](./examples/aws/sqs.py) for direct SQS publishing and [examples/aws/sns.py](./examples/aws/sns.py) for an SNS-to-SQS workflow with routing-key filters.
|
|
77
|
+
|
|
74
78
|
### Async Support
|
|
75
79
|
|
|
76
80
|
```python
|
|
@@ -78,7 +82,7 @@ import asyncio
|
|
|
78
82
|
from weenspace_queue import AsyncQueueClient, Message, QueueSpecification
|
|
79
83
|
|
|
80
84
|
async def main():
|
|
81
|
-
async with AsyncQueueClient("
|
|
85
|
+
async with AsyncQueueClient("RABBITMQ", uri="amqp://localhost:5672/") as client:
|
|
82
86
|
queue = await client.declare_queue(QueueSpecification(name="my-queue"))
|
|
83
87
|
await client.publish(queue, Message(body=b"Async message!"))
|
|
84
88
|
|
|
@@ -91,7 +95,7 @@ asyncio.run(main())
|
|
|
91
95
|
from weenspace_queue import QueueClient
|
|
92
96
|
|
|
93
97
|
client = QueueClient(
|
|
94
|
-
"
|
|
98
|
+
"RABBITMQ",
|
|
95
99
|
uri="amqp://localhost:5672/",
|
|
96
100
|
oauth2_options=your_oauth_options
|
|
97
101
|
)
|
|
@@ -103,7 +107,7 @@ client = QueueClient(
|
|
|
103
107
|
from weenspace_queue import QueueClient
|
|
104
108
|
|
|
105
109
|
client = QueueClient(
|
|
106
|
-
"
|
|
110
|
+
"RABBITMQ",
|
|
107
111
|
uri="amqps://localhost:5671/",
|
|
108
112
|
ssl_context=your_ssl_context
|
|
109
113
|
)
|
|
@@ -30,7 +30,7 @@ pip install weenspace-queue
|
|
|
30
30
|
```python
|
|
31
31
|
from weenspace_queue import Message, QueueClient, QueueSpecification
|
|
32
32
|
|
|
33
|
-
client = QueueClient("
|
|
33
|
+
client = QueueClient("RABBITMQ", uri="amqp://guest:guest@localhost:5672/")
|
|
34
34
|
queue = client.declare_queue(QueueSpecification(name="my-queue"))
|
|
35
35
|
client.publish(queue, Message(body=b"Hello WeenSpace!"))
|
|
36
36
|
|
|
@@ -43,6 +43,10 @@ client.consume(queue, handler=on_message, prefetch=10)
|
|
|
43
43
|
|
|
44
44
|
Install AWS support with `pip install "weenspace-queue[aws]"`.
|
|
45
45
|
|
|
46
|
+
### AWS SQS and SNS
|
|
47
|
+
|
|
48
|
+
See [examples/aws/sqs.py](./examples/aws/sqs.py) for direct SQS publishing and [examples/aws/sns.py](./examples/aws/sns.py) for an SNS-to-SQS workflow with routing-key filters.
|
|
49
|
+
|
|
46
50
|
### Async Support
|
|
47
51
|
|
|
48
52
|
```python
|
|
@@ -50,7 +54,7 @@ import asyncio
|
|
|
50
54
|
from weenspace_queue import AsyncQueueClient, Message, QueueSpecification
|
|
51
55
|
|
|
52
56
|
async def main():
|
|
53
|
-
async with AsyncQueueClient("
|
|
57
|
+
async with AsyncQueueClient("RABBITMQ", uri="amqp://localhost:5672/") as client:
|
|
54
58
|
queue = await client.declare_queue(QueueSpecification(name="my-queue"))
|
|
55
59
|
await client.publish(queue, Message(body=b"Async message!"))
|
|
56
60
|
|
|
@@ -63,7 +67,7 @@ asyncio.run(main())
|
|
|
63
67
|
from weenspace_queue import QueueClient
|
|
64
68
|
|
|
65
69
|
client = QueueClient(
|
|
66
|
-
"
|
|
70
|
+
"RABBITMQ",
|
|
67
71
|
uri="amqp://localhost:5672/",
|
|
68
72
|
oauth2_options=your_oauth_options
|
|
69
73
|
)
|
|
@@ -75,7 +79,7 @@ client = QueueClient(
|
|
|
75
79
|
from weenspace_queue import QueueClient
|
|
76
80
|
|
|
77
81
|
client = QueueClient(
|
|
78
|
-
"
|
|
82
|
+
"RABBITMQ",
|
|
79
83
|
uri="amqps://localhost:5671/",
|
|
80
84
|
ssl_context=your_ssl_context
|
|
81
85
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "weenspace-queue"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.3"
|
|
4
4
|
description = "WeenSpace queue client for RabbitMQ and AWS SQS, supporting both synchronous and asynchronous operations."
|
|
5
5
|
authors = ["WeenSpace <weenspace@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -15,6 +15,22 @@ from .constants import (
|
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
def __getattr__(name: str) -> Any:
|
|
19
|
+
"""Lazily expose the low-level RabbitMQ compatibility API."""
|
|
20
|
+
try:
|
|
21
|
+
from rabbitmq_amqp_python_client import __dict__ as rabbitmq_namespace
|
|
22
|
+
|
|
23
|
+
value = rabbitmq_namespace.get(name)
|
|
24
|
+
if value is None and name == "DirectReplyToConsumerOptions":
|
|
25
|
+
value = rabbitmq_namespace["ConsumerOptions"]
|
|
26
|
+
if value is None:
|
|
27
|
+
raise KeyError(name)
|
|
28
|
+
except (ImportError, KeyError) as exc:
|
|
29
|
+
raise AttributeError(name) from exc
|
|
30
|
+
globals()[name] = value
|
|
31
|
+
return value
|
|
32
|
+
|
|
33
|
+
|
|
18
34
|
def _engine_class(provider: str) -> Type[QueueEngine]:
|
|
19
35
|
if provider == PROVIDER_AWS:
|
|
20
36
|
from .providers.aws import AwsEngine
|
|
@@ -43,7 +59,7 @@ class QueueClient:
|
|
|
43
59
|
"""Single client: pass provider name, then use the same publish/consume/topology methods."""
|
|
44
60
|
|
|
45
61
|
def __init__(self, provider: str, **config: Any) -> None:
|
|
46
|
-
prov_key = provider.
|
|
62
|
+
prov_key = provider.strip().upper()
|
|
47
63
|
engine_cls = _engine_class(prov_key)
|
|
48
64
|
self.provider = prov_key
|
|
49
65
|
self.engine: QueueEngine = engine_cls(**config)
|
|
@@ -86,7 +102,7 @@ class AsyncQueueClient:
|
|
|
86
102
|
"""Async twin of QueueClient. Same method names, same provider argument."""
|
|
87
103
|
|
|
88
104
|
def __init__(self, provider: str, **config: Any) -> None:
|
|
89
|
-
prov_key = provider.
|
|
105
|
+
prov_key = provider.strip().upper()
|
|
90
106
|
engine_cls = _async_engine_class(prov_key)
|
|
91
107
|
self.provider = prov_key
|
|
92
108
|
self.engine: AsyncQueueEngine = engine_cls(**config)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
__all__ = ["AwsAsyncEngine", "RabbitMqAsyncEngine"]
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def __getattr__(name: str) -> Any:
|
|
7
|
+
try:
|
|
8
|
+
from rabbitmq_amqp_python_client.asyncio import __dict__ as rabbitmq_namespace
|
|
9
|
+
|
|
10
|
+
value = rabbitmq_namespace[name]
|
|
11
|
+
globals()[name] = value
|
|
12
|
+
return value
|
|
13
|
+
except (ImportError, KeyError):
|
|
14
|
+
pass
|
|
15
|
+
if name == "AwsAsyncEngine":
|
|
16
|
+
from .aws_async import AwsAsyncEngine
|
|
17
|
+
|
|
18
|
+
return AwsAsyncEngine
|
|
19
|
+
if name == "RabbitMqAsyncEngine":
|
|
20
|
+
from .rabbitmq_async import RabbitMqAsyncEngine
|
|
21
|
+
|
|
22
|
+
return RabbitMqAsyncEngine
|
|
23
|
+
raise AttributeError(name)
|
|
@@ -35,10 +35,10 @@ from weenspace_queue.utils import (
|
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
_EXCHANGE_KIND_MAP = {
|
|
38
|
-
ExchangeKind.DIRECT: ExchangeType.
|
|
39
|
-
ExchangeKind.TOPIC: ExchangeType.
|
|
40
|
-
ExchangeKind.FANOUT: ExchangeType.
|
|
41
|
-
ExchangeKind.HEADERS: ExchangeType.
|
|
38
|
+
ExchangeKind.DIRECT: ExchangeType.direct,
|
|
39
|
+
ExchangeKind.TOPIC: ExchangeType.topic,
|
|
40
|
+
ExchangeKind.FANOUT: ExchangeType.fanout,
|
|
41
|
+
ExchangeKind.HEADERS: ExchangeType.headers,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
__all__ = ["AwsEngine", "RabbitMqEngine"]
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def __getattr__(name: str) -> Any:
|
|
7
|
+
if name == "AwsEngine":
|
|
8
|
+
from .aws import AwsEngine
|
|
9
|
+
|
|
10
|
+
return AwsEngine
|
|
11
|
+
if name == "RabbitMqEngine":
|
|
12
|
+
from .rabbitmq import RabbitMqEngine
|
|
13
|
+
|
|
14
|
+
return RabbitMqEngine
|
|
15
|
+
raise AttributeError(name)
|
|
@@ -30,10 +30,10 @@ from weenspace_queue.utils import (
|
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
_EXCHANGE_KIND_MAP = {
|
|
33
|
-
ExchangeKind.DIRECT: ExchangeType.
|
|
34
|
-
ExchangeKind.TOPIC: ExchangeType.
|
|
35
|
-
ExchangeKind.FANOUT: ExchangeType.
|
|
36
|
-
ExchangeKind.HEADERS: ExchangeType.
|
|
33
|
+
ExchangeKind.DIRECT: ExchangeType.direct,
|
|
34
|
+
ExchangeKind.TOPIC: ExchangeType.topic,
|
|
35
|
+
ExchangeKind.FANOUT: ExchangeType.fanout,
|
|
36
|
+
ExchangeKind.HEADERS: ExchangeType.headers,
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Compatibility namespace for RabbitMQ's bundled Proton API."""
|
|
@@ -24,6 +24,14 @@ from .constants import (
|
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
def __getattr__(name: str) -> Any:
|
|
28
|
+
if name == "Converter":
|
|
29
|
+
from rabbitmq_amqp_python_client.utils import Converter
|
|
30
|
+
|
|
31
|
+
return Converter
|
|
32
|
+
raise AttributeError(name)
|
|
33
|
+
|
|
34
|
+
|
|
27
35
|
def encode_body(body: Any) -> bytes:
|
|
28
36
|
if isinstance(body, bytes):
|
|
29
37
|
return body
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|