Skip to content

Commit 0209d2b

Browse files
committed
Merge pull request apache#323 from datastax/304
PYTHON-304 - Add documentation for connection pool settings
2 parents db88fe1 + 2302a78 commit 0209d2b

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

cassandra/cluster.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,13 @@ def get_min_requests_per_connection(self, host_distance):
660660
return self._min_requests_per_connection[host_distance]
661661

662662
def set_min_requests_per_connection(self, host_distance, min_requests):
663+
"""
664+
Sets a threshold for concurrent requests per connection, below which
665+
connections will be considered for disposal (down to core connections;
666+
see :meth:`~Cluster.set_core_connections_per_host`).
667+
668+
Pertains to connection pool management in protocol versions {1,2}.
669+
"""
663670
if self.protocol_version >= 3:
664671
raise UnsupportedOperation(
665672
"Cluster.set_min_requests_per_connection() only has an effect "
@@ -670,6 +677,13 @@ def get_max_requests_per_connection(self, host_distance):
670677
return self._max_requests_per_connection[host_distance]
671678

672679
def set_max_requests_per_connection(self, host_distance, max_requests):
680+
"""
681+
Sets a threshold for concurrent requests per connection, above which new
682+
connections will be created to a host (up to max connections;
683+
see :meth:`~Cluster.set_max_connections_per_host`).
684+
685+
Pertains to connection pool management in protocol versions {1,2}.
686+
"""
673687
if self.protocol_version >= 3:
674688
raise UnsupportedOperation(
675689
"Cluster.set_max_requests_per_connection() only has an effect "
@@ -695,6 +709,10 @@ def set_core_connections_per_host(self, host_distance, core_connections):
695709
The default is 2 for :attr:`~HostDistance.LOCAL` and 1 for
696710
:attr:`~HostDistance.REMOTE`.
697711
712+
Protocol version 1 and 2 are limited in the number of concurrent
713+
requests they can send per connection. The driver implements connection
714+
pooling to support higher levels of concurrency.
715+
698716
If :attr:`~.Cluster.protocol_version` is set to 3 or higher, this
699717
is not supported (there is always one connection per host, unless
700718
the host is remote and :attr:`connect_to_remote_hosts` is :const:`False`)

docs/api/cassandra/cluster.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@
5757

5858
.. automethod:: unregister_listener
5959

60+
.. automethod:: set_max_requests_per_connection
61+
62+
.. automethod:: get_max_requests_per_connection
63+
64+
.. automethod:: set_min_requests_per_connection
65+
66+
.. automethod:: get_min_requests_per_connection
67+
6068
.. automethod:: get_core_connections_per_host
6169

6270
.. automethod:: set_core_connections_per_host

0 commit comments

Comments
 (0)