You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>A pool of re-usable, interchangeable <code><ahref="Classes/Connection.html">Connection</a></code> instances.</p>
158
+
159
+
<p>Using a <code>ConnectionPool</code> allows an application to acquire an existing <code><ahref="Classes/Connection.html">Connection</a></code> from the
160
+
pool, use that connection to perform one or more SQL statements, and then release it for use
161
+
elsewhere in the application.</p>
162
+
163
+
<p>The <code><ahref="Structs/ConnectionPoolConfiguration.html">ConnectionPoolConfiguration</a></code> used to create a <code>ConnectionPool</code> specifies the number of
164
+
connections in the pool, how long a request for a connection will wait for a connection to
165
+
become available, and other characteristics of the pool.</p>
166
+
167
+
<p>All connections in a <code>ConnectionPool</code> are created from the same <code><ahref="Structs/ConnectionConfiguration.html">ConnectionConfiguration</a></code>.
168
+
They also have the same <code><ahref="Protocols/ConnectionDelegate.html">ConnectionDelegate</a></code> (if a delegate is specified). Consequently
169
+
any connection in a pool is interchangeable with any other.</p>
170
+
171
+
<p>Use <code><ahref="Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07acquireD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF">ConnectionPool.acquireConnection(completionHandler:)</a></code> to request a connection from a
172
+
<code>ConnectionPool</code>. This method is non-blocking: its completion handler is asynchronously
173
+
executed when a connection is successfully allocated to the request or if an error occurs.
174
+
To release the connection back to the pool, call <code><ahref="Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07releaseD0yyAA0D0CF">ConnectionPool.releaseConnection(_:)</a></code>.</p>
175
+
176
+
<p>Alternately, use <code><ahref="Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC04withD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF">ConnectionPool.withConnection(completionHandler:)</a></code> to acquire a connection
177
+
that is automatically released after execution of the completion handler.</p>
178
+
179
+
<p>When a connection is released to a <code>ConnectionPool</code>, there should be no transaction underway.
180
+
Pair each SQL <code>BEGIN</code> command with either a <code>COMMIT</code> or <code>ROLLBACK</code> command (or equivalently,
181
+
use the <code><ahref="Classes/Connection.html#/s:17PostgresClientKit10ConnectionC16beginTransactionyyKF">Connection.beginTransaction()</a></code>, <code><ahref="Classes/Connection.html#/s:17PostgresClientKit10ConnectionC17commitTransactionyyKF">Connection.commitTransaction()</a></code>, and
<p>In general, do not close a <code><ahref="Classes/Connection.html">Connection</a></code> acquired from a <code>ConnectionPool</code>. If a connection is
185
+
closed (whether explicitly or because of an unrecoverable error) then, when that connection is
186
+
released, it will be discarded from the pool, allowing a new connection to be created and added
187
+
to the pool.</p>
188
+
189
+
<p>The <code>ConnectionPool</code> class is threadsafe: multiple threads may concurrently operate against a
190
+
<code>ConnectionPool</code> instance. Connections acquired from the pool are subject to the threadsafety
191
+
constraints described by the API documentation for <code><ahref="Classes/Connection.html">Connection</a></code>.</p>
<p>Closes this <code>Connection</code> abruptly.</p>
323
+
324
+
<p>Unlike <code><ahref="../Classes/Connection.html#/s:17PostgresClientKit10ConnectionC5closeyyF">close()</a></code>, this method does not send a <q>terminate</q> request to the Postgres server;
325
+
it simply closes the network socket.</p>
326
+
327
+
<p>Use this method to force a connection to immediately close, even if another thread is
328
+
concurrently operating against the connection.</p>
0 commit comments