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:
-
Install Lepus using pip:
pip install lepus
-
Import the library into your Python code:
from lepus import Rabbit
-
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
Built Distribution
File details
Details for the file lepus-0.0.4.tar.gz
.
File metadata
- Download URL: lepus-0.0.4.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a441489f76758df77c8d36a5fba668b70d2f2f3f1facbc49a7c847a2c4155f48 |
|
MD5 | 1e1c19263c5041dd5ef86446c7dcac54 |
|
BLAKE2b-256 | fa2283cf01bd6c012fdd75d6c9745ee39c67557850b286c557c9a49c488f018f |
File details
Details for the file lepus-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: lepus-0.0.4-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d6e9a2349e8cf7d156a96f4e7a5f73e767664a7aa6eeebc7b6fe00cb3e56409 |
|
MD5 | 2c0caf475da131825588bdd84f1820a6 |
|
BLAKE2b-256 | c56cf9a9d06799ae5740b87875708012a10b0c3f96bf6c3eab5b822113d30811 |