Coder Social home page Coder Social logo

nidhaloff / b-rabbit Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 9.0 1.8 MB

A thread safe library that aims to provide a simple API for interfacing with RabbitMQ. Built on top of rabbitpy, the library make it very easy to use the RabbitMQ message broker with just few lines of code. It implements all messaging pattern used by message brokers

License: MIT License

Python 91.94% Makefile 8.06%
thread-safe multithreading parallel-computing concurency rabbitmq message-broker mircroservice loose-coupling rabbit-mq rabbitpy

b-rabbit's People

Contributors

arstotzk avatar gabriel10619 avatar nidhaloff avatar phmakowski avatar wiseaidev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

b-rabbit's Issues

add more tests

Description

This issue is great for new comers who want to join the project. You can write more tests to test the functionality. Feel free to work on this or discuss it with me

Move from `setup.cfg`, `setup.py`, `MANIFEST.in`, and `requirements.txt` to `pyproject.toml`.

  • b_rabbit version: 1.2.4
  • Python version: 3.9
  • Operating System: Ubuntu 20.04

Description

Hey @nidhaloff! As you may already know, the use of setup.cfg, setup.py, MANIFEST.in, and requirements.txt files is quite outdated. Because of PEP 517, PEP 660, and PEP 631, the packaging is now being standardized on the usage of the pyproject.toml file.

What I want to do

Given the above info, I have updated the project packaging to support pyproject.toml, and ultimately i will add support for poetry(optional).

A `RuntimeError` is being thrown when instantiating a `BRabbit` object.

  • b_rabbit version: 1.2.4
  • Python version: 3.9.10
  • Operating System: Ubuntu 20.04

Description

I am trying to contribute unit tests for this project. However, I am getting a RuntimeError whenever I create an instance of class BRabbit.

What I Did

from b_rabbit import BRabbit
rabbit = BRabbit(host='localhost', port=5672)

Output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/harmouch/b-rabbit/b_rabbit/b_rabbit.py", line 59, in __init__
    self.connection = rabbitpy.Connection(
  File "/home/harmouch/b-rabbit/.venv/lib/python3.9/site-packages/rabbitpy-2.0.1-py3.9.egg/rabbitpy/connection.py", line 131, in __init__
    self._connect()
  File "/home/harmouch/b-rabbit/.venv/lib/python3.9/site-packages/rabbitpy-2.0.1-py3.9.egg/rabbitpy/connection.py", line 301, in _connect
    raise RuntimeError("Timeout waiting for opening the socket")
RuntimeError: Timeout waiting for opening the socket

helpers.logs doesnt exist

b_rabbit version: latest
Python version: 3.8.6
Operating System: macos

Description

when importing b-rabbit it looks for helpers.logs which doesnt exist.
(on github it does, so I think you should use .helpers.logs or something)

What I Did

Traceback (most recent call last):
  File "serve.py", line 1, in <module>
    from b_rabbit import BRabbit
  File "/Users/oshochat/Library/Python/3.8/lib/python/site-packages/b_rabbit/__init__.py", line 3, in <module>
    from .b_rabbit import BRabbit
  File "/Users/oshochat/Library/Python/3.8/lib/python/site-packages/b_rabbit/b_rabbit.py", line 8, in <module>
    from helpers.logs import create_logger
ModuleNotFoundError: No module named 'helpers.logs'

Add more low-level features

The EventSubscriber and EventPublisher are the easiest ways to get your b-rabbit messenger service up and running. Currently, it is only utilizing a portion of the low-level features that rabbitpy and RabbitMQ provides.

If you would like to contribute to the project, adding these features to the mentioned classes would be a great way to help brabbit become a more dynamic solution to AMPQ with multithreading support.

Here are some examples of features that could be implemented:

[Feature]: Rethinking package classes design pattern.

Description

Hey @nidhaloff, I have a question related to the design pattern followed in this class. For me it looks redundant. Take a look at its usage in the tests:

def rabbit():
return BRabbit()

In order to create an EventPublisher, you have to call the inner class and pass the outer reference, BRabbit, as a parameter to the __init__ function:

publisher = rabbit.EventPublisher(b_rabbit=rabbit,

It kind of looks unnecessary to do so since you already have the outer reference, the BRabbit instance. It looks like a self-reference problem or something of that nature. Also, I think this way it will allocate unnecessary space in memory.

Solution

All Inner classes should be moved outside the BRabbit class for better design.

Message received unnecessary print

Hi I'm new to Rabbit but have been using your project as a wrapper for it and like how much simpler you've made it. The one issue I'm finding is that it prints a message to console every time a message is received, and there is no way to turn this off, however I can see it looks like a one line change (pprint(True) -> pprint(False)) in a subcribe method. Any chance you can add an option to turn this off completely?

Why I would like to change the current logging model

The following code snippet is an example of how adding the helpers file to your local directory can only save you for so long. In this example, the helpers file had been copied to every directory containing code in which b-rabbit was being imported, but the code is still unable to function when using a python dependency manager (At least it doesn't work when using poetry). Hopefully this will be fixed by the end of the week!

../../../.cache/pypoetry/virtualenvs/sectry-8eJmSxWQ-py3.7/lib/python3.7/site-packages/b_rabbit/init.py:3: in
from .b_rabbit import BRabbit
../../../.cache/pypoetry/virtualenvs/sectry-8eJmSxWQ-py3.7/lib/python3.7/site-packages/b_rabbit/b_rabbit.py:8: in
from helpers.logs import create_logger
E ModuleNotFoundError: No module named 'helpers'
Error: Process completed with exit code 4.

Errors in example

  • b_rabbit version: master
  • Python version: 3.8.1
  • Operating System: macOS

Description

Running the scripts in the example in the README I get the following error

Task Response received
bytearray(b'return this value to requester')
Traceback (most recent call last):
  File "./requster.py", line 16, in <module>
    rabbit.close_connection()
  File "/Users/zrgorak/Development/b_rabbit/b_rabbit/b_rabbit.py", line 50, in close_connection
    self._shutdown_gracefully()
  File "/Users/zrgorak/Development/b_rabbit/b_rabbit/b_rabbit.py", line 60, in _shutdown_gracefully
    activeQueue.stop_consuming()
  File "/Users/zrgorak/.pyenv/versions/b_rabbit/lib/python3.8/site-packages/rabbitpy/amqp_queue.py", line 342, in stop_consuming
    raise exceptions.NotConsumingError()
rabbitpy.exceptions.NotConsumingError: No active consumer to cancel
% pip freeze 
appdirs==1.4.4
b-rabbit @ file:///Users/zrgorak/Development/b_rabbit
distlib==0.3.1
filelock==3.0.12
packaging==20.4
pamqp==2.3.0
pluggy==0.13.1
py==1.9.0
pyparsing==2.4.7
rabbitpy==2.0.1
six==1.15.0
toml==0.10.1
tox==3.19.0
virtualenv==20.0.30

Seems like you either have to check if the queue is consuming or just wrap in a try catch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.