Skip to content

Commit c90c069

Browse files
author
DanielePalaia
committed
some improvements
1 parent 6c86328 commit c90c069

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22

33
This library is in early stages of development. It is meant to be used with RabbitMQ 4.0.
44

5-
## How to Run
5+
## How to Build the project and run the tests
6+
7+
- Start a RabbitMQ 4.x broker
8+
- poetry build: build the source project
9+
- poetry install: resolves and install dependencies
10+
- poetry run pytest: run the tests
611

712
## Getting Started
813

14+
An example is provide in ./getting_started_main.py you can run it after starting a RabbitMQ 4.0 broker with:
15+
16+
poetry run python ./examples/getting_started/main.py
17+
918

examples/getting_started/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import time
2+
13
from rabbitmq_amqp_python_client import (
24
BindingSpecification,
35
Connection,
@@ -48,7 +50,7 @@ def main() -> None:
4850
print("unbind")
4951
management.unbind(bind_name)
5052

51-
print("purging queue")
53+
print("purging the queue")
5254
management.purge_queue(queue_name)
5355

5456
print("delete queue")

rabbitmq_amqp_python_client/connection.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@ def management(self) -> Management:
2828

2929
# closes the connection to the AMQP 1.0 server.
3030
def close(self) -> None:
31+
logger.debug("Closing connection")
3132
self._conn.close()
3233

3334
def publisher(self, destination: str) -> Publisher:
3435
publisher = Publisher(self._conn, destination)
3536
return publisher
36-
37-
# TODO: returns the current status of the connection.
38-
# def status(self) -> int:
39-
# pass

rabbitmq_amqp_python_client/entities.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ class QueueSpecification:
3131
class BindingSpecification:
3232
source_exchange: str
3333
destination_queue: str
34-
# destination_exchange: str
3534
binding_key: str

rabbitmq_amqp_python_client/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ class ValidationCodeException(Exception):
33
def __init__(self, msg: str):
44
self.msg = msg
55

6-
# __str__ is to print() the value
76
def __str__(self) -> str:
87
return repr(self.msg)

rabbitmq_amqp_python_client/management.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ def _validate_reponse_code(
191191
"wrong response code received: " + str(response_code)
192192
)
193193

194-
# TODO
195194
def bind(self, bind_specification: BindingSpecification) -> str:
196195
logger.debug("Bind Operation called")
197196
body = {}
@@ -214,7 +213,6 @@ def bind(self, bind_specification: BindingSpecification) -> str:
214213
binding_path_with_queue = binding_path_with_exchange_queue(bind_specification)
215214
return binding_path_with_queue
216215

217-
# TODO
218216
def unbind(self, binding_exchange_queue_path: str) -> None:
219217
logger.debug("UnBind Operation called")
220218
self.request(
@@ -226,16 +224,10 @@ def unbind(self, binding_exchange_queue_path: str) -> None:
226224
],
227225
)
228226

229-
# TODO
230-
# def queue_info(self, queue_name:str):
231-
232-
# TODO
233227
def purge_queue(self, queue_name: str) -> None:
234228
logger.debug("purge_queue operation called")
235229
path = purge_queue_address(queue_name)
236230

237-
print("path: " + path)
238-
239231
self.request(
240232
None,
241233
path,

rabbitmq_amqp_python_client/publisher.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ def publish(self, message: Message) -> None:
3030
self._sender.send(message)
3131

3232
def close(self) -> None:
33+
logger.debug("Closing Sender and Receiver")
3334
if self._sender is not None:
3435
self._sender.close()
35-
# if self._receiver is not None:
36-
# self._receiver.close()
36+
if self._receiver is not None:
37+
self._receiver.close()
3738

3839
def _create_sender(self, addr: str) -> BlockingSender:
3940
return self._conn.create_sender(addr, options=SenderOption(addr))

0 commit comments

Comments
 (0)