Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding ssl flags

  • Loading branch information...
commit f643a327231efef3c8df314fb60e4b31ec8a613b 1 parent 7a9f440
@buzztroll buzztroll authored
Showing with 28 additions and 10 deletions.
  1. +2 −2 dashi/__init__.py
  2. +13 −2 dashi/bootstrap/__init__.py
  3. +13 −6 examples/talk.py
View
4 dashi/__init__.py
@@ -21,7 +21,7 @@ class DashiConnection(object):
#TODO support connection info instead of uri
def __init__(self, name, uri, exchange, durable=False, auto_delete=True,
- serializer=None, transport_options=None):
+ serializer=None, transport_options=None, ssl=False):
"""Set up a Dashi connection
@param name: name of destination service queue used by consumers
@@ -35,7 +35,7 @@ def __init__(self, name, uri, exchange, durable=False, auto_delete=True,
@param transport_options: custom parameter dict for the transport backend
"""
- self._conn = BrokerConnection(uri, transport_options=transport_options)
+ self._conn = BrokerConnection(uri, transport_options=transport_options,ssl=ssl)
self._name = name
self._exchange_name = exchange
self._exchange = Exchange(name=exchange, type='direct',
View
15 dashi/bootstrap/__init__.py
@@ -72,10 +72,15 @@ def dashi_connect(topic, CFG=None, amqp_uri=None):
if 'memory' in CFG.server:
amqp_uri = "memory://%s" % (CFG.server.memory.name)
else:
- amqp_uri = "amqp://%s:%s@%s/%s" % (
+ try:
+ port_str = ":%d" % (CFG.server.amqp.port)
+ except AttributeError:
+ port_str = ""
+ amqp_uri = "amqp://%s:%s@%s%s/%s" % (
CFG.server.amqp.username,
CFG.server.amqp.password,
CFG.server.amqp.host,
+ port_str,
CFG.server.amqp.vhost,
)
@@ -96,8 +101,14 @@ def dashi_connect(topic, CFG=None, amqp_uri=None):
except AttributeError:
serializer = None
+ try:
+ ssl = CFG.server.ssl
+ ssl = True
+ except AttributeError:
+ ssl = False
+
return DashiConnection(topic, amqp_uri, dashi_exchange,
- serializer=serializer, transport_options=transport_options)
+ serializer=serializer, transport_options=transport_options, ssl=ssl)
def enable_gevent():
View
19 examples/talk.py
@@ -3,6 +3,8 @@
from threading import Thread
from dashi import DashiConnection
+g_rabbit_url = ""
+
class TalkConsole(object):
def __init__(self):
@@ -23,8 +25,9 @@ def __init__(self, console, name):
Thread.__init__(self)
self.name = name
self.done = False
- self.exchange = "dashitalkexchange"
- self.dashi = DashiConnection(self.name, "amqp://guest:guest@127.0.0.1//", self.exchange)
+ self.exchange = "default_dashi_exchange"
+ global g_rabbit_url
+ self.dashi = DashiConnection(self.name, g_rabbit_url, self.exchange, ssl=True)
self.subscribers = []
self.console = console
self.dashi.handle(self.new_joined_chat, "new_joined_chat")
@@ -62,11 +65,15 @@ def end(self):
self.input_message("%s has left the room" % (self.name))
def main(argv):
- my_name = argv[0]
+ global g_rabbit_url
+ g_rabbit_url = argv[0]
+ my_name = argv[1]
console = TalkConsole()
talker = DashiTalker(console, my_name)
- if len(argv) > 1:
- talker.request_conversation(argv[1])
+ if len(argv) > 2:
+ print "request"
+ print argv[2]
+ talker.request_conversation(argv[2])
talker.start()
done = False
@@ -80,4 +87,4 @@ def main(argv):
if __name__ == '__main__':
rc = main(sys.argv[1:])
- sys.exit(rc)
+ sys.exit(rc)
Please sign in to comment.
Something went wrong with that request. Please try again.