Skip to content
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
6 changes: 5 additions & 1 deletion aredis/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def to_bool(value):
URL_QUERY_ARGUMENT_PARSERS = {
'stream_timeout': float,
'connect_timeout': float,
'retry_on_timeout': to_bool
'retry_on_timeout': to_bool,
'max_connections': int,
'max_idle_time': int,
'idle_check_interval': int,
'reader_read_size': int
}


Expand Down
90 changes: 89 additions & 1 deletion tests/client/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def test_connection_idle_check(self, event_loop):
assert last_active_at == conn.last_active_at
assert conn._writer is None and conn._reader is None


class TestConnectionPoolURLParsing:
def test_defaults(self):
pool = aredis.ConnectionPool.from_url('redis://localhost')
Expand Down Expand Up @@ -225,6 +225,50 @@ def test_invalid_extra_typed_querystring_options(self):
'Invalid value for `stream_timeout` in connection URL.',
]

def test_max_connections_querystring_option(self):
pool = aredis.ConnectionPool.from_url('redis://localhost?max_connections=32')
assert pool.connection_class == aredis.Connection
assert pool.connection_kwargs == {
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None,
'max_connections': 32
}

def test_max_idle_times_querystring_option(self):
pool = aredis.ConnectionPool.from_url('redis://localhost?max_idle_time=5')
assert pool.connection_class == aredis.Connection
assert pool.connection_kwargs == {
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None,
'max_idle_time': 5
}

def test_idle_check_interval_querystring_option(self):
pool = aredis.ConnectionPool.from_url('redis://localhost?idle_check_interval=1')
assert pool.connection_class == aredis.Connection
assert pool.connection_kwargs == {
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None,
'idle_check_interval': 1
}

def test_reader_read_size_querystring_option(self):
pool = aredis.ConnectionPool.from_url('redis://localhost?reader_read_size=65535')
assert pool.connection_class == aredis.Connection
assert pool.connection_kwargs == {
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None,
'reader_read_size': 65535
}

def test_extra_querystring_options(self):
pool = aredis.ConnectionPool.from_url('redis://localhost?a=1&b=2')
assert pool.connection_class == aredis.Connection
Expand Down Expand Up @@ -307,6 +351,50 @@ def test_db_in_querystring(self):
'password': None,
}

def test_max_connections_querystring_option(self):
pool = aredis.ConnectionPool.from_url('unix:///localhost?max_connections=32')
assert pool.connection_class == aredis.Connection
assert pool.connection_kwargs == {
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None,
'max_connections': 32
}

def test_max_idle_times_querystring_option(self):
pool = aredis.ConnectionPool.from_url('unix:///localhost?max_idle_time=5')
assert pool.connection_class == aredis.Connection
assert pool.connection_kwargs == {
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None,
'max_idle_time': 5
}

def test_idle_check_interval_querystring_option(self):
pool = aredis.ConnectionPool.from_url('unix:///localhost?idle_check_interval=1')
assert pool.connection_class == aredis.Connection
assert pool.connection_kwargs == {
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None,
'idle_check_interval': 1
}

def test_reader_read_size_querystring_option(self):
pool = aredis.ConnectionPool.from_url('unix:///localhost?reader_read_size=65535')
assert pool.connection_class == aredis.Connection
assert pool.connection_kwargs == {
'host': 'localhost',
'port': 6379,
'db': 0,
'password': None,
'reader_read_size': 65535
}

def test_extra_querystring_options(self):
pool = aredis.ConnectionPool.from_url('unix:///socket?a=1&b=2')
assert pool.connection_class == aredis.UnixDomainSocketConnection
Expand Down