Skip to main content

Using RabbitMQ with Python in a simplified way.

Project description

Lepus

Using RabbitMQ with Python in a simplified way.

Lepus is a Python library designed to streamline integration with RabbitMQ, a robust and widely-used messaging system. The name "Lepus" pays homage to the constellation of the hare (Lepus), which is one of the many constellations that dot the night sky. Similarly, Lepus simplifies communication between your application's components, allowing them to efficiently and reliably exchange information without the complexity of managing RabbitMQ's low-level details.

Why Lepus?

RabbitMQ is a popular choice for implementing message systems due to its reliability, scalability, and support for various communication protocols. However, dealing directly with RabbitMQ using Pika, the official Python library for RabbitMQ interaction, can be a challenging task. Lepus was created with the aim of simplifying this process, making it more accessible for developers who want to focus on their application's business logic rather than worrying about low-level details.

Getting Started

To start using Lepus in your project, follow these simple steps:

  1. Install Lepus using pip:

    pip install lepus
    
  2. Import the library into your Python code:

    from lepus import Rabbit
    
  3. Declare queues and exchanges, configure message handling, and start efficiently exchanging information with RabbitMQ.

    rabbit = Rabbit('config.json')
    
    @rabbit.listener(queue='my-queue')
    def callback(ch, method, properties, body):
        print(f" [x] Received {body}")
    
    rabbit.publish("Hello World!", routing_key='my-queue')
    

Lepus provides a smooth and effective development experience for RabbitMQ integration, enabling you to make the most of the power of this powerful messaging tool.

Contribution

Lepus is an open-source project, and we encourage contributions from the community. Feel free to open issues, submit pull requests, or help improve the documentation. Together, we can make Lepus even better.

Documentation

As mentioned above, almost all configuration must be in a JSON file. This configuration will be used when instantiating the Rabbit object in the example above (in our example, config.json). Here is the list of settings: Certainly, here is the first table in English:

Root properties

Property Description
host The host address for the RabbitMQ connection.
port The RabbitMQ host port for the connection.
blocked_connection_timeout The timeout for blocked connections.
channel_max The maximum number of allowed communication channels.
client_properties RabbitMQ client properties.
connection_attempts The number of connection attempts allowed.
frame_max The maximum frame size for communication.
heartbeat The timeout for maintaining the heartbeat connection.
locale The locale for communication with RabbitMQ.
retry_delay The delay between connection retry attempts.
socket_timeout The timeout for socket operations.
stack_timeout The timeout for communication stack operations.
virtual_host The virtual host for the RabbitMQ connection.
queues List of queues (See details in the lists below)
exchanges List of exchanges (See details in the lists below)

Queue Properties

Property Description
name The name of the queue.
passive Whether the queue is passive (default: False).
durable Whether the queue is durable (default: False).
exclusive Whether the queue is exclusive (default: False).
auto_delete Whether the queue is auto-deleted (default: False).
arguments Additional arguments for the queue (default: None).

These properties define the characteristics and behavior of a RabbitMQ queue.

Exchange Properties

Property Description
name The name of the exchange.
type The type of the exchange (default: 'fanout').
passive Whether the exchange is passive (default: False).
durable Whether the exchange is durable (default: False).
auto_delete Whether the exchange is auto-deleted (default: False).
internal Whether the exchange is internal (default: False).
arguments Additional arguments for the exchange (default: None).

Credentials Variables

We have two crucial properties, username and password, are sourced from environment variables. These environment variables play a pivotal role in establishing secure authentication with RabbitMQ. Here is a brief explanation of each, along with a list:

Environment Variable Description
RABBIT_USERNAME The user identifier for authentication with RabbitMQ.
RABBIT_PASSWORD The secret passphrase associated with username for authentication.

by default: guest / guest

License

Lepus is distributed under the GNU General Public Licience. Please read the LICENSE file for details on the license terms.

Contact

If you have any questions, suggestions, or need assistance, don't hesitate to reach out to us at Marcos Stefani Rosa or visit our GitHub page for more information.

If you want to collaborate so that we can continue to have innovative ideas and more time to invest in these projects, contribute to our Patreon.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lepus-0.0.4.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

lepus-0.0.4-py3-none-any.whl (17.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page