PythonCloudFrameworks / bunny-storm

RabbitMQ asynchronous connector library for Python with built in RPC support
MIT License
23 stars 9 forks source link

Please support ssl connection string #19

Open TomerGershi opened 2 years ago

TomerGershi commented 2 years ago

Support ssl connection (needed for AWS RabbitMQ service) changes needed only in rabbitmq_connection_data.py:

--- a/bunny_storm/rabbitmq_connection_data.py
+++ b/bunny_storm/rabbitmq_connection_data.py
@@ -14,6 +14,7 @@ class RabbitMQConnectionData:
     port: int = 5672
     virtual_host: str = "/"
     connection_name: str = ""
+    ssl: bool = False

     def uri(self) -> str:
         """
@@ -22,4 +23,5 @@ class RabbitMQConnectionData:
         """
         vhost = "" if self.virtual_host == "/" else self.virtual_host
         name_query = f"?name={self.connection_name}" if self.connection_name else ""
-        return f"amqp://{self.username}:{self.password}@{self.host}:{self.port}/{vhost}{name_query}"
+        header = "amqps" if self.ssl else "amqp"
+        return f"{header}://{self.username}:{self.password}@{self.host}:{self.port}/{vhost}{name_query}"

Didn't had permissions to post PR myself.

Thanks, Tomer

odedshimon commented 2 years ago

Hi @TomerGershi!

Thanks for suggesting this, it is a small change but indeed important.

I prefer that you create a PR (you need to fork this repo, then create a pull request to this repo, Please see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork for detailed instructions).

If from some reason you still having problems to create a PR, please let us know and we will manually modify it.

Thanks, Oded