Skip to content

Commit 9123a31

Browse files
Thread max_total_rows through ClusterClient + ConnectionPool
Cycle 9 — the cumulative row-cap knob added earlier only reached as far as DqliteConnection. ClusterClient.connect() and ConnectionPool now accept and forward max_total_rows so every layer above the raw protocol can set it from one place. Default is still 10_000_000; None disables the cap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6380e4b commit 9123a31

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/dqliteclient/cluster.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,28 @@ async def _query_leader(self, address: str) -> str | None:
148148
finally:
149149
writer.close()
150150

151-
async def connect(self, database: str = "default") -> DqliteConnection:
151+
async def connect(
152+
self,
153+
database: str = "default",
154+
*,
155+
max_total_rows: int | None = 10_000_000,
156+
) -> DqliteConnection:
152157
"""Connect to the cluster leader.
153158
154-
Returns a connection to the current leader.
159+
Returns a connection to the current leader. ``max_total_rows``
160+
is forwarded to the underlying :class:`DqliteConnection` so
161+
callers (including :class:`ConnectionPool`) can tune the
162+
cumulative row cap from one place.
155163
"""
156164

157165
async def try_connect() -> DqliteConnection:
158166
leader = await self.find_leader()
159-
conn = DqliteConnection(leader, database=database, timeout=self._timeout)
167+
conn = DqliteConnection(
168+
leader,
169+
database=database,
170+
timeout=self._timeout,
171+
max_total_rows=max_total_rows,
172+
)
160173
await conn.connect()
161174
return conn
162175

src/dqliteclient/pool.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(
5757
timeout: float = 10.0,
5858
cluster: ClusterClient | None = None,
5959
node_store: NodeStore | None = None,
60+
max_total_rows: int | None = 10_000_000,
6061
) -> None:
6162
"""Initialize connection pool.
6263
@@ -91,6 +92,7 @@ def __init__(
9192
self._min_size = min_size
9293
self._max_size = max_size
9394
self._timeout = timeout
95+
self._max_total_rows = max_total_rows
9496

9597
if cluster is not None:
9698
self._cluster = cluster
@@ -124,7 +126,9 @@ async def initialize(self) -> None:
124126

125127
async def _create_connection(self) -> DqliteConnection:
126128
"""Create a new connection to the leader."""
127-
conn = await self._cluster.connect(database=self._database)
129+
conn = await self._cluster.connect(
130+
database=self._database, max_total_rows=self._max_total_rows
131+
)
128132
self._size += 1
129133
return conn
130134

0 commit comments

Comments
 (0)