Skip to content

Commit

Permalink
Starting ProxyRepository and Proxy with an IO loop
Browse files Browse the repository at this point in the history
  • Loading branch information
diogobaeder committed Mar 25, 2013
1 parent 244f19d commit cb45f9f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ lint:
@flake8 . --ignore=E501

install:
pip install -r $(MAIN_REQUIREMENTS) --use-mirrors
pip install -r requirements-py$(PYTHON_MAJOR_VERSION).txt --use-mirrors
@echo Installing dependencies...
@pip install -r $(MAIN_REQUIREMENTS) --use-mirrors
-@[ -f $(EXTENDED_REQUIREMENTS) ] && pip install -r $(EXTENDED_REQUIREMENTS) --use-mirrors || \
echo File "$(EXTENDED_REQUIREMENTS)" doesn\'t exist, skipping version-specific packages
@echo Finished installing dependencies.
2 changes: 1 addition & 1 deletion memcrashed/handlers/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BinaryProtocolHandler(object):
def __init__(self, io_loop):
self.io_loop = io_loop
self.parser = BinaryParser()
self.pool_repository = ProxyRepository()
self.pool_repository = ProxyRepository(self.io_loop)

@gen.engine
def process(self, client_stream, backend_stream, callback):
Expand Down
2 changes: 1 addition & 1 deletion memcrashed/handlers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TextProtocolHandler(object):
def __init__(self, io_loop):
self.io_loop = io_loop
self.parser = TextParser()
self.pool_repository = ProxyRepository()
self.pool_repository = ProxyRepository(self.io_loop)

@gen.engine
def process(self, client_stream, backend_stream, callback):
Expand Down
8 changes: 6 additions & 2 deletions memcrashed/proxy.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
class ProxyRepository(object):
def __init__(self, io_loop):
self.io_loop = io_loop

def proxy_for_key(self, key):
return Proxy(key)
return Proxy(key, self.io_loop)


class Proxy(object):
def __init__(self, key):
def __init__(self, key, io_loop):
self.key = key
self.io_loop = io_loop
3 changes: 2 additions & 1 deletion tests/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
class ProxyRepositoryTest(ServerTestCase):
@istest
def gets_proxy_for_key(self):
repository = ProxyRepository()
repository = ProxyRepository(self.io_loop)

proxy = repository.proxy_for_key('foo')

self.assertIsInstance(proxy, Proxy)
self.assertEqual(proxy.key, 'foo')
self.assertEqual(proxy.io_loop, self.io_loop)

0 comments on commit cb45f9f

Please sign in to comment.