mirror of https://github.com/celery/kombu.git
First attempt to enable Mongo Replicasets
This commit is contained in:
parent
8920f0d837
commit
3cd0eb6f1b
|
@ -38,19 +38,24 @@ URI_FORMAT = """\
|
|||
|
||||
|
||||
def parse_url(url):
|
||||
port = path = None
|
||||
auth = userid = password = None
|
||||
scheme = urlparse(url).scheme
|
||||
parts = urlparse(url.replace("%s://" % (scheme, ), "http://"))
|
||||
netloc = parts.netloc
|
||||
if '@' in netloc:
|
||||
auth, _, netloc = partition(parts.netloc, '@')
|
||||
userid, _, password = partition(auth, ':')
|
||||
hostname, _, port = partition(netloc, ':')
|
||||
path = parts.path or ""
|
||||
if path and path[0] == '/':
|
||||
path = path[1:]
|
||||
if scheme != 'mongodb':
|
||||
netloc = parts.netloc
|
||||
if '@' in netloc:
|
||||
auth, _, netloc = partition(parts.netloc, '@')
|
||||
userid, _, password = partition(auth, ':')
|
||||
hostname, _, port = partition(netloc, ':')
|
||||
path = parts.path or ""
|
||||
if path and path[0] == '/':
|
||||
path = path[1:]
|
||||
port = int(port)
|
||||
else:
|
||||
hostname = url[len('mongodb://'):]
|
||||
return dict({"hostname": hostname,
|
||||
"port": port and int(port) or None,
|
||||
"port": port or None,
|
||||
"userid": userid or None,
|
||||
"password": password or None,
|
||||
"transport": scheme,
|
||||
|
@ -386,14 +391,15 @@ class BrokerConnection(object):
|
|||
port = fields["port"]
|
||||
userid = fields["userid"]
|
||||
password = fields["password"]
|
||||
url = "%s://" % fields["transport"]
|
||||
transport = fields["transport"]
|
||||
url = "%s://" % transport
|
||||
if userid:
|
||||
url += userid
|
||||
if include_password and password:
|
||||
url += ':' + password
|
||||
url += '@'
|
||||
url += fields["hostname"]
|
||||
if port:
|
||||
if port and transport != "mongodb":
|
||||
url += ':' + str(port)
|
||||
url += '/' + fields["virtual_host"]
|
||||
return url
|
||||
|
|
Loading…
Reference in New Issue