Connectiva: A Unified Microservice Communication Library
Connectiva is a powerful and flexible Python library designed to streamline communication across diverse microservices architectures. Whether you're using REST APIs, gRPC, Kafka, WebSockets, or traditional message brokers, Connectiva provides a unified interface to handle all your communication needs effortlessly.
- Protocol Agnostic: Automatically detects and adapts to the communication protocol being used, whether it's REST, gRPC, Kafka, RabbitMQ, WebSockets, GraphQL, or file-based communication.
- Ease of Use: Leverages an intuitive, consistent API that allows you to connect, send, receive, and disconnect seamlessly across different communication methods.
- Extensibility: Built with modularity in mind, allowing developers to extend or customize communication strategies as needed.
- Efficiency: Utilizes efficient connection management and message handling to ensure robust performance in high-load environments.
Connectiva can be easily installed using Poetry, a dependency management tool for Python.
To install Connectiva using Poetry, run the following command:
poetry add connectiva
Alternatively, you can install Connectiva using pip:
pip install connectiva
Connectiva supports the following communication protocols:
- REST APIs
- gRPC
- Kafka
- RabbitMQ (and other message brokers)
- WebSockets
- GraphQL
- File-based communication
Here's a quick guide to using Connectiva in your Python projects:
from connectiva import Connectiva, Message
# Instantiate Connectiva with desired configuration
connectiva = Connectiva(
endpoint="kafka://localhost:9092",
broker_list="localhost:9092",
topic="my_topic",
group_id="my_group"
)
connectiva.connect()
message = Message(action="process", data="Hello, Kafka!")
response = connectiva.send(message)
print(f"Response: {response}")
received_message = connectiva.receive()
print(f"Received: {received_message}")
connectiva.disconnect()
Connectiva is designed to be flexible and can be configured to suit your needs. Here's an example configuration:
connectiva = Connectiva(
endpoint="grpc://localhost:50051",
topic="my_topic",
queue_name="my_queue",
)
Connectiva is built with extensibility in mind. You can easily extend the library by adding new communication strategies or customizing existing ones. Simply create a new strategy class that implements the CommunicationMethod
interface and add it to the strategy map.
We welcome contributions to Connectiva! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes and commit them.
- Push your changes to your fork.
- Create a pull request on the main repository.
Please ensure that your code follows the project's style guidelines and includes appropriate tests.
Connectiva is released under the MIT License. See the LICENSE file for more details.
- Ali Tavallaie - [email protected]
Thank you for using Connectiva! We hope it simplifies your microservice communication needs.