amqp-client-python 0.1.14__tar.gz → 0.2.0__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.
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/PKG-INFO +64 -54
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/README.md +54 -53
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/domain/models/config.py +32 -2
- amqp_client_python-0.2.0/amqp_client_python/domain/models/options.py +63 -0
- amqp_client_python-0.2.0/amqp_client_python/domain/models/ssl_options.py +23 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/domain/utils/__init__.py +1 -0
- amqp_client_python-0.2.0/amqp_client_python/domain/utils/types.py +7 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/auto_reconnect_exception.py +2 -2
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/blocking_exception.py +3 -3
- amqp_client_python-0.2.0/amqp_client_python/exceptions/eventbus_exception.py +7 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/nack_exception.py +2 -2
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/publish_timeout_exception.py +2 -2
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/response_timeout_exception.py +2 -2
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/rpc_provider_exception.py +3 -3
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/thread_unsafe_exception.py +3 -3
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/timeout_exception.py +2 -2
- amqp_client_python-0.2.0/amqp_client_python/py.typed +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/async_channel.py +136 -103
- amqp_client_python-0.2.0/amqp_client_python/rabbitmq/async_channel_factory.py +11 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/async_connection.py +38 -49
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/async_connection_factory.py +4 -3
- amqp_client_python-0.2.0/amqp_client_python/rabbitmq/async_eventbus_rabbitmq.py +308 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/channel_factory_rabbitmq.py +3 -1
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/channel_rabbitmq.py +28 -25
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/connection_factory_rabbitmq.py +4 -3
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/connection_rabbitmq.py +12 -10
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/eventbus_rabbitmq.py +22 -8
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/eventbus_wrapper_rabbitmq.py +42 -27
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/ioloop_factory.py +3 -2
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/signals.py +9 -8
- amqp_client_python-0.2.0/pyproject.toml +75 -0
- amqp_client_python-0.1.14/amqp_client_python/domain/models/options.py +0 -31
- amqp_client_python-0.1.14/amqp_client_python/domain/models/ssl_options.py +0 -7
- amqp_client_python-0.1.14/amqp_client_python/exceptions/eventbus_exception.py +0 -7
- amqp_client_python-0.1.14/amqp_client_python/rabbitmq/async_channel_factory.py +0 -6
- amqp_client_python-0.1.14/amqp_client_python/rabbitmq/async_eventbus_rabbitmq.py +0 -161
- amqp_client_python-0.1.14/pyproject.toml +0 -37
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/LICENSE +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/__init__.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/domain/models/__init__.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/domain/utils/connection_type.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/event/__init__.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/event/async_provider_handler.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/event/async_subscriber_handler.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/event/event.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/event/integration_event.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/event/integration_event_handler.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/event/provider_handler.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/event/subscriber_handler.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/exceptions/__init__.py +0 -0
- {amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/rabbitmq/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: amqp-client-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Python AMQP Client Library
|
|
5
5
|
Home-page: https://github.com/nutes-uepb/amqp-client-python
|
|
6
6
|
License: Apache-2.0
|
|
@@ -8,13 +8,23 @@ Keywords: packaging,dependency,amqp-client-python
|
|
|
8
8
|
Author: NUTES UEPB
|
|
9
9
|
Author-email: dev.seniorsaudemovel@gmail.com
|
|
10
10
|
Requires-Python: >=3.7,<4.0
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
11
13
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
12
16
|
Classifier: Programming Language :: Python :: 3
|
|
13
17
|
Classifier: Programming Language :: Python :: 3.7
|
|
14
18
|
Classifier: Programming Language :: Python :: 3.8
|
|
15
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
16
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Communications
|
|
24
|
+
Classifier: Topic :: Internet
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Classifier: Topic :: System :: Networking
|
|
18
28
|
Requires-Dist: pika (>=1.3.0,<2.0.0)
|
|
19
29
|
Project-URL: Bug Tracker, https://github.com/nutes-uepb/amqp-client-python/issues
|
|
20
30
|
Project-URL: Repository, https://github.com/nutes-uepb/amqp-client-python
|
|
@@ -22,6 +32,10 @@ Description-Content-Type: text/markdown
|
|
|
22
32
|
|
|
23
33
|
# AMQP Client Python
|
|
24
34
|
|
|
35
|
+
Client with high level of abstraction for manipulation of messages in the event bus RabbitMQ.
|
|
36
|
+
|
|
37
|
+
--------
|
|
38
|
+
|
|
25
39
|
[![License][license-image]][license-url]
|
|
26
40
|
<a href="https://pypi.org/project/amqp-client-python" target="_blank">
|
|
27
41
|
<img src="https://img.shields.io/pypi/v/amqp-client-python?color=%2334D058&label=pypi%20package" alt="Package version">
|
|
@@ -33,10 +47,13 @@ Description-Content-Type: text/markdown
|
|
|
33
47
|
|
|
34
48
|
|
|
35
49
|
|
|
50
|
+
---
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
Client with high level of abstraction for manipulation of messages in the event bus RabbitMQ.
|
|
52
|
+
**Documentation**: <a href="https://nutes-uepb.github.io/amqp-client-python" target="_blank">https://nutes-uepb.github.io/amqp-client-python</a>
|
|
39
53
|
|
|
54
|
+
**Source Code**: <a href="https://github.com/nutes-uepb/amqp-client-python" target="_blank">https://github.com/nutes-uepb/amqp-client-python</a>
|
|
55
|
+
|
|
56
|
+
---
|
|
40
57
|
### Features:
|
|
41
58
|
- Automatic creation and management of queues, exchanges and channels;
|
|
42
59
|
- Connection persistence and auto reconnect;
|
|
@@ -46,19 +63,11 @@ Client with high level of abstraction for manipulation of messages in the event
|
|
|
46
63
|
- Support for a Remote procedure call _(RPC)_.
|
|
47
64
|
|
|
48
65
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
[downloads-image]: https://img.shields.io/npm/dt/amqp-client-python.svg?logo=npm
|
|
55
|
-
[travis-url]: https://travis-ci.org/nutes-uepb/amqp-client-python
|
|
56
|
-
[coverage-image]: https://coveralls.io/repos/github/nutes-uepb/amqp-client-python/badge.svg
|
|
57
|
-
[coverage-url]: https://coveralls.io/github/nutes-uepb/amqp-client-python?branch=master
|
|
58
|
-
[known-vulnerabilities-image]: https://snyk.io/test/github/nutes-uepb/amqp-client-python/badge.svg?targetFile=requirements.txt
|
|
59
|
-
[known-vulnerabilities-url]: https://snyk.io/test/github/nutes-uepb/amqp-client-python?targetFile=requirements.txt
|
|
60
|
-
[releases-image]: https://img.shields.io/github/release-date/nutes-uepb/amqp-client-python.svg
|
|
61
|
-
[releases-url]: https://github.com/nutes-uepb/amqp-client-python/releases
|
|
66
|
+
### Table of Compatibility
|
|
67
|
+
| version | compatible with |
|
|
68
|
+
| ---- | ---- |
|
|
69
|
+
| 0.2.0 | 0.2.0 |
|
|
70
|
+
| 0.1.14 | ~0.1.12 |
|
|
62
71
|
|
|
63
72
|
### Examples:
|
|
64
73
|
#### you can use [sync](https://github.com/nutes-uepb/amqp-client-python/blob/develop/amqp_client_python/rabbitmq/eventbus_rabbitmq.py) , [async eventbus](https://github.com/nutes-uepb/amqp-client-python/blob/develop/amqp_client_python/rabbitmq/async_eventbus_rabbitmq.py) and [sync wrapper](https://github.com/nutes-uepb/amqp-client-python/blob/develop/amqp_client_python/rabbitmq/eventbus_wrapper_rabbitmq.py) of async eventbus
|
|
@@ -72,34 +81,26 @@ from amqp_client_python import (
|
|
|
72
81
|
AsyncEventbusRabbitMQ,
|
|
73
82
|
Config, Options
|
|
74
83
|
)
|
|
75
|
-
from amqp_client_python.event import IntegrationEvent, IntegrationEventHandler
|
|
76
84
|
config = Config(Options("queue", "rpc_queue", "rpc_exchange"))
|
|
77
85
|
eventbus = AsyncEventbusRabbitMQ(config)
|
|
78
86
|
# publish
|
|
79
|
-
class ExampleEvent(IntegrationEvent):
|
|
80
|
-
EVENT_NAME: str = "ExampleEvent"
|
|
81
|
-
def __init__(self, event_type: str, message = []) -> None:
|
|
82
|
-
super().__init__(self.EVENT_NAME, event_type)
|
|
83
|
-
self.message = message
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
eventbus.publish(publish_event, rpc_routing_key, "direct")
|
|
88
|
+
eventbus.publish("rpc_exchange", "routing.key", "message_content")
|
|
87
89
|
# subscribe
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
await eventbus.subscribe(subscribe_event, subscribe_event_handle, rpc_routing_key)
|
|
90
|
+
async def subscribe_handler(body) -> None:
|
|
91
|
+
print(body, type(body), flush=True) # handle messages
|
|
92
|
+
await eventbus.subscribe("rpc_exchange", "routing.key", subscribe_handler)
|
|
92
93
|
# rpc_publish
|
|
93
|
-
response = await eventbus.rpc_client(rpc_exchange, "user.find",
|
|
94
|
+
response = await eventbus.rpc_client("rpc_exchange", "user.find", "message_content")
|
|
94
95
|
# provider
|
|
95
|
-
async def
|
|
96
|
+
async def rpc_provider_handler(body) -> bytes:
|
|
96
97
|
print(f"body: {body}")
|
|
97
98
|
return b"content"
|
|
98
|
-
await eventbus.provide_resource("user.find",
|
|
99
|
+
await eventbus.provide_resource("user.find", rpc_provider_handler)
|
|
99
100
|
```
|
|
100
101
|
</details>
|
|
101
102
|
|
|
102
|
-
<details><summary>sync usage</summary>
|
|
103
|
+
<details><summary>sync usage(deprecated)</summary>
|
|
103
104
|
|
|
104
105
|
```Python
|
|
105
106
|
from amqp_client_python import (
|
|
@@ -153,7 +154,7 @@ while running:
|
|
|
153
154
|
count += 1
|
|
154
155
|
if str(count) != eventbus.rpc_client(rpc_exchange, rpc_routing_key+"2", [f"{count}"]).decode("utf-8"):
|
|
155
156
|
running = False
|
|
156
|
-
#eventbus.publish(publish_event, rpc_routing_key, "
|
|
157
|
+
#eventbus.publish(publish_event, rpc_routing_key, "message_content")
|
|
157
158
|
#running = False
|
|
158
159
|
except TimeoutError as err:
|
|
159
160
|
print("timeout!!!: ", str(err))
|
|
@@ -168,40 +169,30 @@ while running:
|
|
|
168
169
|
|
|
169
170
|
```Python
|
|
170
171
|
from amqp_client_python import EventbusWrapperRabbitMQ, Config, Options
|
|
171
|
-
from amqp_client_python.event import IntegrationEvent, IntegrationEventHandler
|
|
172
172
|
|
|
173
|
-
config = Config(Options(queue, rpc_queue, rpc_exchange))
|
|
173
|
+
config = Config(Options("queue", "rpc_queue", "rpc_exchange"))
|
|
174
174
|
eventbus = EventbusWrapperRabbitMQ(config=config)
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
def __init__(self, event_type: str, message = []) -> None:
|
|
179
|
-
super().__init__(self.EVENT_NAME, event_type)
|
|
180
|
-
self.message = message
|
|
181
|
-
class ExampleEventHandler(IntegrationEventHandler):
|
|
182
|
-
async def handle(self, body) -> None:
|
|
183
|
-
print(body,"subscribe")
|
|
176
|
+
async def subscribe_handler(body) -> None:
|
|
177
|
+
print(f"{body}", type(body), flush=True)
|
|
184
178
|
|
|
185
|
-
async def
|
|
186
|
-
print(body
|
|
187
|
-
return f"{body
|
|
179
|
+
async def rpc_provider_handler(body) -> bytes:
|
|
180
|
+
print(f"handle - {body}", type(body), flush=True)
|
|
181
|
+
return f"{body}".encode("utf-8")
|
|
188
182
|
|
|
189
|
-
subscribe_event = ExampleEvent(rpc_exchange)
|
|
190
|
-
publish_event = ExampleEvent(rpc_exchange, ["message"])
|
|
191
|
-
subscribe_event_handle = ExampleEventHandler()
|
|
192
183
|
# rpc_provider
|
|
193
|
-
eventbus.provide_resource(
|
|
184
|
+
eventbus.provide_resource("user.find", rpc_provider_handler).result()
|
|
194
185
|
# subscribe
|
|
195
|
-
eventbus.subscribe(
|
|
186
|
+
eventbus.subscribe("rpc_exchange", "routing.key", subscribe_handler).result()
|
|
196
187
|
count = 0
|
|
197
188
|
running = True
|
|
198
189
|
while running:
|
|
199
190
|
try:
|
|
200
191
|
count += 1
|
|
201
192
|
# rpc_client call
|
|
202
|
-
eventbus.rpc_client(rpc_exchange,
|
|
193
|
+
eventbus.rpc_client("rpc_exchange", "user.find", count).result().decode("utf-8")
|
|
203
194
|
# publish
|
|
204
|
-
eventbus.publish(
|
|
195
|
+
eventbus.publish("rpc_exchange", "routing.key", "message_content").result()
|
|
205
196
|
#running = False
|
|
206
197
|
except KeyboardInterrupt:
|
|
207
198
|
running=False
|
|
@@ -211,12 +202,31 @@ while running:
|
|
|
211
202
|
</details>
|
|
212
203
|
<br />
|
|
213
204
|
|
|
205
|
+
|
|
206
|
+
## Sponsors
|
|
207
|
+
The library is provided by NUTES-UEPB.
|
|
208
|
+
<br/>
|
|
209
|
+
<a href="https://nutes.uepb.edu.br/" target="_blank"><img width="250px" src="https://nutes.uepb.edu.br/wp-content/uploads/2018/11/cropped-logo-Nutes-Final.jpg"></a>
|
|
210
|
+
|
|
214
211
|
### Know Limitations:
|
|
215
212
|
#### basic eventbus
|
|
216
213
|
<medium><pre>
|
|
217
|
-
When using [**EventbusRabbitMQ**](https://github.com/nutes-uepb/amqp-client-python/blob/master/amqp_client_python/rabbitmq/eventbus_rabbitmq.py#L12) Should not use rpc call inside of rpc provider
|
|
214
|
+
When using [**EventbusRabbitMQ**](https://github.com/nutes-uepb/amqp-client-python/blob/master/amqp_client_python/rabbitmq/eventbus_rabbitmq.py#L12) Should not use rpc call inside of rpc provider or subscribe handlers, it may block the ioloop
|
|
218
215
|
#/obs: fixed on other kinds of eventbus, will be removed on nexts releases
|
|
219
216
|
</pre></medium>
|
|
220
217
|
|
|
221
218
|
|
|
222
219
|
|
|
220
|
+
[//]: # (These are reference links used in the body of this note.)
|
|
221
|
+
[license-image]: https://img.shields.io/badge/license-Apache%202-blue.svg
|
|
222
|
+
[license-url]: https://github.com/nutes-uepb/amqp-client-python/blob/master/LICENSE
|
|
223
|
+
[npm-image]: https://img.shields.io/npm/v/amqp-client-python.svg?color=red&logo=npm
|
|
224
|
+
[npm-url]: https://npmjs.org/package/amqp-client-python
|
|
225
|
+
[downloads-image]: https://img.shields.io/npm/dt/amqp-client-python.svg?logo=npm
|
|
226
|
+
[travis-url]: https://travis-ci.org/nutes-uepb/amqp-client-python
|
|
227
|
+
[coverage-image]: https://coveralls.io/repos/github/nutes-uepb/amqp-client-python/badge.svg
|
|
228
|
+
[coverage-url]: https://coveralls.io/github/nutes-uepb/amqp-client-python?branch=master
|
|
229
|
+
[known-vulnerabilities-image]: https://snyk.io/test/github/nutes-uepb/amqp-client-python/badge.svg?targetFile=requirements.txt
|
|
230
|
+
[known-vulnerabilities-url]: https://snyk.io/test/github/nutes-uepb/amqp-client-python?targetFile=requirements.txt
|
|
231
|
+
[releases-image]: https://img.shields.io/github/release-date/nutes-uepb/amqp-client-python.svg
|
|
232
|
+
[releases-url]: https://github.com/nutes-uepb/amqp-client-python/releases
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# AMQP Client Python
|
|
2
2
|
|
|
3
|
+
Client with high level of abstraction for manipulation of messages in the event bus RabbitMQ.
|
|
4
|
+
|
|
5
|
+
--------
|
|
6
|
+
|
|
3
7
|
[![License][license-image]][license-url]
|
|
4
8
|
<a href="https://pypi.org/project/amqp-client-python" target="_blank">
|
|
5
9
|
<img src="https://img.shields.io/pypi/v/amqp-client-python?color=%2334D058&label=pypi%20package" alt="Package version">
|
|
@@ -11,10 +15,13 @@
|
|
|
11
15
|
|
|
12
16
|
|
|
13
17
|
|
|
18
|
+
---
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
Client with high level of abstraction for manipulation of messages in the event bus RabbitMQ.
|
|
20
|
+
**Documentation**: <a href="https://nutes-uepb.github.io/amqp-client-python" target="_blank">https://nutes-uepb.github.io/amqp-client-python</a>
|
|
17
21
|
|
|
22
|
+
**Source Code**: <a href="https://github.com/nutes-uepb/amqp-client-python" target="_blank">https://github.com/nutes-uepb/amqp-client-python</a>
|
|
23
|
+
|
|
24
|
+
---
|
|
18
25
|
### Features:
|
|
19
26
|
- Automatic creation and management of queues, exchanges and channels;
|
|
20
27
|
- Connection persistence and auto reconnect;
|
|
@@ -24,19 +31,11 @@ Client with high level of abstraction for manipulation of messages in the event
|
|
|
24
31
|
- Support for a Remote procedure call _(RPC)_.
|
|
25
32
|
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
[downloads-image]: https://img.shields.io/npm/dt/amqp-client-python.svg?logo=npm
|
|
33
|
-
[travis-url]: https://travis-ci.org/nutes-uepb/amqp-client-python
|
|
34
|
-
[coverage-image]: https://coveralls.io/repos/github/nutes-uepb/amqp-client-python/badge.svg
|
|
35
|
-
[coverage-url]: https://coveralls.io/github/nutes-uepb/amqp-client-python?branch=master
|
|
36
|
-
[known-vulnerabilities-image]: https://snyk.io/test/github/nutes-uepb/amqp-client-python/badge.svg?targetFile=requirements.txt
|
|
37
|
-
[known-vulnerabilities-url]: https://snyk.io/test/github/nutes-uepb/amqp-client-python?targetFile=requirements.txt
|
|
38
|
-
[releases-image]: https://img.shields.io/github/release-date/nutes-uepb/amqp-client-python.svg
|
|
39
|
-
[releases-url]: https://github.com/nutes-uepb/amqp-client-python/releases
|
|
34
|
+
### Table of Compatibility
|
|
35
|
+
| version | compatible with |
|
|
36
|
+
| ---- | ---- |
|
|
37
|
+
| 0.2.0 | 0.2.0 |
|
|
38
|
+
| 0.1.14 | ~0.1.12 |
|
|
40
39
|
|
|
41
40
|
### Examples:
|
|
42
41
|
#### you can use [sync](https://github.com/nutes-uepb/amqp-client-python/blob/develop/amqp_client_python/rabbitmq/eventbus_rabbitmq.py) , [async eventbus](https://github.com/nutes-uepb/amqp-client-python/blob/develop/amqp_client_python/rabbitmq/async_eventbus_rabbitmq.py) and [sync wrapper](https://github.com/nutes-uepb/amqp-client-python/blob/develop/amqp_client_python/rabbitmq/eventbus_wrapper_rabbitmq.py) of async eventbus
|
|
@@ -50,34 +49,26 @@ from amqp_client_python import (
|
|
|
50
49
|
AsyncEventbusRabbitMQ,
|
|
51
50
|
Config, Options
|
|
52
51
|
)
|
|
53
|
-
from amqp_client_python.event import IntegrationEvent, IntegrationEventHandler
|
|
54
52
|
config = Config(Options("queue", "rpc_queue", "rpc_exchange"))
|
|
55
53
|
eventbus = AsyncEventbusRabbitMQ(config)
|
|
56
54
|
# publish
|
|
57
|
-
class ExampleEvent(IntegrationEvent):
|
|
58
|
-
EVENT_NAME: str = "ExampleEvent"
|
|
59
|
-
def __init__(self, event_type: str, message = []) -> None:
|
|
60
|
-
super().__init__(self.EVENT_NAME, event_type)
|
|
61
|
-
self.message = message
|
|
62
55
|
|
|
63
|
-
|
|
64
|
-
eventbus.publish(publish_event, rpc_routing_key, "direct")
|
|
56
|
+
eventbus.publish("rpc_exchange", "routing.key", "message_content")
|
|
65
57
|
# subscribe
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
await eventbus.subscribe(subscribe_event, subscribe_event_handle, rpc_routing_key)
|
|
58
|
+
async def subscribe_handler(body) -> None:
|
|
59
|
+
print(body, type(body), flush=True) # handle messages
|
|
60
|
+
await eventbus.subscribe("rpc_exchange", "routing.key", subscribe_handler)
|
|
70
61
|
# rpc_publish
|
|
71
|
-
response = await eventbus.rpc_client(rpc_exchange, "user.find",
|
|
62
|
+
response = await eventbus.rpc_client("rpc_exchange", "user.find", "message_content")
|
|
72
63
|
# provider
|
|
73
|
-
async def
|
|
64
|
+
async def rpc_provider_handler(body) -> bytes:
|
|
74
65
|
print(f"body: {body}")
|
|
75
66
|
return b"content"
|
|
76
|
-
await eventbus.provide_resource("user.find",
|
|
67
|
+
await eventbus.provide_resource("user.find", rpc_provider_handler)
|
|
77
68
|
```
|
|
78
69
|
</details>
|
|
79
70
|
|
|
80
|
-
<details><summary>sync usage</summary>
|
|
71
|
+
<details><summary>sync usage(deprecated)</summary>
|
|
81
72
|
|
|
82
73
|
```Python
|
|
83
74
|
from amqp_client_python import (
|
|
@@ -131,7 +122,7 @@ while running:
|
|
|
131
122
|
count += 1
|
|
132
123
|
if str(count) != eventbus.rpc_client(rpc_exchange, rpc_routing_key+"2", [f"{count}"]).decode("utf-8"):
|
|
133
124
|
running = False
|
|
134
|
-
#eventbus.publish(publish_event, rpc_routing_key, "
|
|
125
|
+
#eventbus.publish(publish_event, rpc_routing_key, "message_content")
|
|
135
126
|
#running = False
|
|
136
127
|
except TimeoutError as err:
|
|
137
128
|
print("timeout!!!: ", str(err))
|
|
@@ -146,40 +137,30 @@ while running:
|
|
|
146
137
|
|
|
147
138
|
```Python
|
|
148
139
|
from amqp_client_python import EventbusWrapperRabbitMQ, Config, Options
|
|
149
|
-
from amqp_client_python.event import IntegrationEvent, IntegrationEventHandler
|
|
150
140
|
|
|
151
|
-
config = Config(Options(queue, rpc_queue, rpc_exchange))
|
|
141
|
+
config = Config(Options("queue", "rpc_queue", "rpc_exchange"))
|
|
152
142
|
eventbus = EventbusWrapperRabbitMQ(config=config)
|
|
153
143
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
def __init__(self, event_type: str, message = []) -> None:
|
|
157
|
-
super().__init__(self.EVENT_NAME, event_type)
|
|
158
|
-
self.message = message
|
|
159
|
-
class ExampleEventHandler(IntegrationEventHandler):
|
|
160
|
-
async def handle(self, body) -> None:
|
|
161
|
-
print(body,"subscribe")
|
|
144
|
+
async def subscribe_handler(body) -> None:
|
|
145
|
+
print(f"{body}", type(body), flush=True)
|
|
162
146
|
|
|
163
|
-
async def
|
|
164
|
-
print(body
|
|
165
|
-
return f"{body
|
|
147
|
+
async def rpc_provider_handler(body) -> bytes:
|
|
148
|
+
print(f"handle - {body}", type(body), flush=True)
|
|
149
|
+
return f"{body}".encode("utf-8")
|
|
166
150
|
|
|
167
|
-
subscribe_event = ExampleEvent(rpc_exchange)
|
|
168
|
-
publish_event = ExampleEvent(rpc_exchange, ["message"])
|
|
169
|
-
subscribe_event_handle = ExampleEventHandler()
|
|
170
151
|
# rpc_provider
|
|
171
|
-
eventbus.provide_resource(
|
|
152
|
+
eventbus.provide_resource("user.find", rpc_provider_handler).result()
|
|
172
153
|
# subscribe
|
|
173
|
-
eventbus.subscribe(
|
|
154
|
+
eventbus.subscribe("rpc_exchange", "routing.key", subscribe_handler).result()
|
|
174
155
|
count = 0
|
|
175
156
|
running = True
|
|
176
157
|
while running:
|
|
177
158
|
try:
|
|
178
159
|
count += 1
|
|
179
160
|
# rpc_client call
|
|
180
|
-
eventbus.rpc_client(rpc_exchange,
|
|
161
|
+
eventbus.rpc_client("rpc_exchange", "user.find", count).result().decode("utf-8")
|
|
181
162
|
# publish
|
|
182
|
-
eventbus.publish(
|
|
163
|
+
eventbus.publish("rpc_exchange", "routing.key", "message_content").result()
|
|
183
164
|
#running = False
|
|
184
165
|
except KeyboardInterrupt:
|
|
185
166
|
running=False
|
|
@@ -189,11 +170,31 @@ while running:
|
|
|
189
170
|
</details>
|
|
190
171
|
<br />
|
|
191
172
|
|
|
173
|
+
|
|
174
|
+
## Sponsors
|
|
175
|
+
The library is provided by NUTES-UEPB.
|
|
176
|
+
<br/>
|
|
177
|
+
<a href="https://nutes.uepb.edu.br/" target="_blank"><img width="250px" src="https://nutes.uepb.edu.br/wp-content/uploads/2018/11/cropped-logo-Nutes-Final.jpg"></a>
|
|
178
|
+
|
|
192
179
|
### Know Limitations:
|
|
193
180
|
#### basic eventbus
|
|
194
181
|
<medium><pre>
|
|
195
|
-
When using [**EventbusRabbitMQ**](https://github.com/nutes-uepb/amqp-client-python/blob/master/amqp_client_python/rabbitmq/eventbus_rabbitmq.py#L12) Should not use rpc call inside of rpc provider
|
|
182
|
+
When using [**EventbusRabbitMQ**](https://github.com/nutes-uepb/amqp-client-python/blob/master/amqp_client_python/rabbitmq/eventbus_rabbitmq.py#L12) Should not use rpc call inside of rpc provider or subscribe handlers, it may block the ioloop
|
|
196
183
|
#/obs: fixed on other kinds of eventbus, will be removed on nexts releases
|
|
197
184
|
</pre></medium>
|
|
198
185
|
|
|
199
186
|
|
|
187
|
+
|
|
188
|
+
[//]: # (These are reference links used in the body of this note.)
|
|
189
|
+
[license-image]: https://img.shields.io/badge/license-Apache%202-blue.svg
|
|
190
|
+
[license-url]: https://github.com/nutes-uepb/amqp-client-python/blob/master/LICENSE
|
|
191
|
+
[npm-image]: https://img.shields.io/npm/v/amqp-client-python.svg?color=red&logo=npm
|
|
192
|
+
[npm-url]: https://npmjs.org/package/amqp-client-python
|
|
193
|
+
[downloads-image]: https://img.shields.io/npm/dt/amqp-client-python.svg?logo=npm
|
|
194
|
+
[travis-url]: https://travis-ci.org/nutes-uepb/amqp-client-python
|
|
195
|
+
[coverage-image]: https://coveralls.io/repos/github/nutes-uepb/amqp-client-python/badge.svg
|
|
196
|
+
[coverage-url]: https://coveralls.io/github/nutes-uepb/amqp-client-python?branch=master
|
|
197
|
+
[known-vulnerabilities-image]: https://snyk.io/test/github/nutes-uepb/amqp-client-python/badge.svg?targetFile=requirements.txt
|
|
198
|
+
[known-vulnerabilities-url]: https://snyk.io/test/github/nutes-uepb/amqp-client-python?targetFile=requirements.txt
|
|
199
|
+
[releases-image]: https://img.shields.io/github/release-date/nutes-uepb/amqp-client-python.svg
|
|
200
|
+
[releases-url]: https://github.com/nutes-uepb/amqp-client-python/releases
|
{amqp_client_python-0.1.14 → amqp_client_python-0.2.0}/amqp_client_python/domain/models/config.py
RENAMED
|
@@ -9,16 +9,46 @@ class Config:
|
|
|
9
9
|
def __init__(
|
|
10
10
|
self, options: Options, ssl_options: Optional[SSLOptions] = None
|
|
11
11
|
) -> None:
|
|
12
|
+
"""
|
|
13
|
+
Create an Config object thats hold and mount the connection information.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
options: hold information for estabilish connection
|
|
17
|
+
ssl_options: hold information for estabilish SSL connections
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
|
|
21
|
+
Raises:
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
>>> Config(
|
|
25
|
+
Options("example", "example.rpc", "example.rpc", "amqp://admin:admin@localhost:5672/"),
|
|
26
|
+
SSLOptions("./.certs/cert.pem", "./.certs/privkey.pem", "./.certs/ca.pem")
|
|
27
|
+
)
|
|
28
|
+
"""
|
|
12
29
|
self.url = None
|
|
13
30
|
self.options = options
|
|
14
31
|
self.ssl_options = ssl_options
|
|
15
32
|
|
|
16
|
-
def build(self):
|
|
33
|
+
def build(self) -> "Config":
|
|
34
|
+
"""
|
|
35
|
+
Create an Config object thats hold and mount the connection information.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Config object
|
|
41
|
+
|
|
42
|
+
Raises:
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
>>> config.build()
|
|
46
|
+
"""
|
|
17
47
|
opt = {
|
|
18
48
|
**self.options.kwargs,
|
|
19
49
|
"heartbeat": self.options.heartbeat,
|
|
20
50
|
}
|
|
21
|
-
if
|
|
51
|
+
if self.ssl_options is not None:
|
|
22
52
|
protocol = "amqps"
|
|
23
53
|
if self.options.port is None:
|
|
24
54
|
self.options.port = 5671
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from typing import Optional, Dict, Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Options:
|
|
5
|
+
def __init__(
|
|
6
|
+
self,
|
|
7
|
+
queue_name: str,
|
|
8
|
+
rpc_queue_name: str,
|
|
9
|
+
rpc_exchange_name: str,
|
|
10
|
+
uri: Optional[str] = None,
|
|
11
|
+
login: str = "guest",
|
|
12
|
+
passwd: str = "guest",
|
|
13
|
+
domain: str = "localhost",
|
|
14
|
+
port: Optional[int] = None,
|
|
15
|
+
vhost: str = "/",
|
|
16
|
+
heartbeat: Optional[int] = 60,
|
|
17
|
+
publisher_confirms: bool = False,
|
|
18
|
+
**kwargs: Dict[str, Any]
|
|
19
|
+
) -> None:
|
|
20
|
+
"""
|
|
21
|
+
Create an Options object that hold the credentials and configs options.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
queue_name: name of queue that will be used for subscriptions
|
|
25
|
+
rpc_queue_name: name of queue that will be used for provide resources
|
|
26
|
+
rpc_exchange_name: name of exchange that will be used for provide resources
|
|
27
|
+
uri: uri for connection
|
|
28
|
+
login: username
|
|
29
|
+
passwd: password
|
|
30
|
+
domain: domain
|
|
31
|
+
port: port information
|
|
32
|
+
vhost: vhost information
|
|
33
|
+
heartbeat: interval between heartbeat
|
|
34
|
+
publisher_confirms: wait for publisher confirmations
|
|
35
|
+
**kwargs: pika options
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
|
|
39
|
+
Raises:
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
>>> Options("example", "example.rpc", "example.rpc", "amqp://admin:admin@localhost:5672/")
|
|
43
|
+
|
|
44
|
+
>>> Options("example", "example.rpc", "example.rpc", "amqps://admin:admin@localhost:5671/")
|
|
45
|
+
|
|
46
|
+
>>> Options("example", "example.rpc", "example.rpc", login="admin", passwd="admin",
|
|
47
|
+
domain="localhost", port=5672)
|
|
48
|
+
|
|
49
|
+
>>> Options("example", "example.rpc", "example.rpc", login="admin", passwd="admin",
|
|
50
|
+
domain="localhost", port=5671)
|
|
51
|
+
"""
|
|
52
|
+
self.queue_name = queue_name
|
|
53
|
+
self.rpc_queue_name = rpc_queue_name
|
|
54
|
+
self.rpc_exchange_name = rpc_exchange_name
|
|
55
|
+
self.uri = uri
|
|
56
|
+
self.login = login
|
|
57
|
+
self.passwd = passwd
|
|
58
|
+
self.domain = domain
|
|
59
|
+
self.port = port
|
|
60
|
+
self.vhost = vhost
|
|
61
|
+
self.heartbeat = heartbeat
|
|
62
|
+
self.publisher_confirms = publisher_confirms
|
|
63
|
+
self.kwargs = kwargs
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class SSLOptions:
|
|
2
|
+
def __init__(
|
|
3
|
+
self, certfile_path: str, keyfile_path: str, ca_certs_path: str
|
|
4
|
+
) -> None:
|
|
5
|
+
"""
|
|
6
|
+
Create an SslOptions object that hold the certs paths.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
certfile_path: cert file path string
|
|
10
|
+
keyfile_path: private key file path string
|
|
11
|
+
ca_certs_path: ca file path string
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
Um dicionário com as notas da escala e os graus.
|
|
15
|
+
|
|
16
|
+
Raises:
|
|
17
|
+
|
|
18
|
+
Examples:
|
|
19
|
+
>>> SSLOptions("./.certs/cert.pem", "./.certs/privkey.pem", "./.certs/ca.pem")
|
|
20
|
+
"""
|
|
21
|
+
self.certfile_path = certfile_path
|
|
22
|
+
self.keyfile_path = keyfile_path
|
|
23
|
+
self.ca_certs_path = ca_certs_path
|
|
@@ -2,8 +2,8 @@ from .eventbus_exception import EventBusException
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class AutoReconnectException(EventBusException):
|
|
5
|
-
message: str =
|
|
6
|
-
description: str =
|
|
5
|
+
message: str = ""
|
|
6
|
+
description: str = ""
|
|
7
7
|
|
|
8
8
|
def __init__(self, message, description="") -> None:
|
|
9
9
|
self.message = message
|
|
@@ -2,9 +2,9 @@ from .eventbus_exception import EventBusException
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class BlockingException(EventBusException):
|
|
5
|
-
message: str =
|
|
6
|
-
description: str =
|
|
5
|
+
message: str = ""
|
|
6
|
+
description: str = ""
|
|
7
7
|
|
|
8
|
-
def __init__(self, message, description="") -> None:
|
|
8
|
+
def __init__(self, message: str, description="") -> None:
|
|
9
9
|
self.message = message
|
|
10
10
|
self.description = description
|
|
@@ -2,8 +2,8 @@ from .eventbus_exception import EventBusException
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class NackException(EventBusException):
|
|
5
|
-
message: str =
|
|
6
|
-
description: str =
|
|
5
|
+
message: str = ""
|
|
6
|
+
description: str = ""
|
|
7
7
|
|
|
8
8
|
def __init__(self, message, description="") -> None:
|
|
9
9
|
self.message = message
|
|
@@ -2,8 +2,8 @@ from .timeout_exception import TimeoutException
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class PublishTimeoutException(TimeoutException):
|
|
5
|
-
message: str =
|
|
6
|
-
description: str =
|
|
5
|
+
message: str = ""
|
|
6
|
+
description: str = ""
|
|
7
7
|
|
|
8
8
|
def __init__(self, message, description="") -> None:
|
|
9
9
|
self.message = message
|
|
@@ -2,8 +2,8 @@ from .timeout_exception import TimeoutException
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class ResponseTimeoutException(TimeoutException):
|
|
5
|
-
message: str =
|
|
6
|
-
description: str =
|
|
5
|
+
message: str = ""
|
|
6
|
+
description: str = ""
|
|
7
7
|
|
|
8
8
|
def __init__(self, message, description="") -> None:
|
|
9
9
|
self.message = message
|
|
@@ -2,9 +2,9 @@ from .eventbus_exception import EventBusException
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class RpcProviderException(EventBusException):
|
|
5
|
-
message: str =
|
|
6
|
-
description: str =
|
|
5
|
+
message: str = ""
|
|
6
|
+
description: str = ""
|
|
7
7
|
|
|
8
|
-
def __init__(self, message, description="") -> None:
|
|
8
|
+
def __init__(self, message: str, description="") -> None:
|
|
9
9
|
self.message = message
|
|
10
10
|
self.description = description
|
|
@@ -2,9 +2,9 @@ from .eventbus_exception import EventBusException
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class ThreadUnsafeException(EventBusException):
|
|
5
|
-
message: str =
|
|
6
|
-
description: str =
|
|
5
|
+
message: str = ""
|
|
6
|
+
description: str = ""
|
|
7
7
|
|
|
8
|
-
def __init__(self, message, description="") -> None:
|
|
8
|
+
def __init__(self, message: str, description="") -> None:
|
|
9
9
|
self.message = message
|
|
10
10
|
self.description = description
|