Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for amqps #1389

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flower/api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ async def get(self):
app = self.application

http_api = None
if app.transport == 'amqp' and app.options.broker_api:
if app.transport in ('amqp','amqps') and app.options.broker_api:
http_api = app.options.broker_api

broker = Broker(app.capp.connection().as_uri(include_password=True),
Expand Down
8 changes: 5 additions & 3 deletions flower/utils/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
class BrokerBase:
def __init__(self, broker_url, *_, **__):
purl = urlparse(broker_url)
self.scheme = purl.scheme
self.host = purl.hostname
self.port = purl.port
self.vhost = purl.path[1:]
Expand All @@ -40,13 +41,14 @@ def __init__(self, broker_url, http_api, io_loop=None, **__):
self.io_loop = io_loop or ioloop.IOLoop.instance()

self.host = self.host or 'localhost'
self.port = self.port or 15672
self.port = self.port or (15671 if self.scheme == 'amqps' else 15672)
self.vhost = quote(self.vhost, '') or '/' if self.vhost != '/' else self.vhost
self.username = self.username or 'guest'
self.password = self.password or 'guest'

if not http_api:
http_api = f"http://{self.username}:{self.password}@{self.host}:{self.port}/api/{self.vhost}"
http_scheme = 'https' if self.scheme == 'amqps' else 'http'
http_api = f"{http_scheme}://{self.username}:{self.password}@{self.host}:{self.port}/api/{self.vhost}"

try:
self.validate_http_api(http_api)
Expand Down Expand Up @@ -228,7 +230,7 @@ def _get_redis_client_args(self):
class Broker:
def __new__(cls, broker_url, *args, **kwargs):
scheme = urlparse(broker_url).scheme
if scheme == 'amqp':
if scheme in ('amqp','amqps'):
return RabbitMQ(broker_url, *args, **kwargs)
if scheme == 'redis':
return Redis(broker_url, *args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion flower/views/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async def get(self):
app = self.application

http_api = None
if app.transport == 'amqp' and app.options.broker_api:
if app.transport in ('amqp','amqps') and app.options.broker_api:
http_api = app.options.broker_api

try:
Expand Down
Loading