Skip to content

Commit 393f175

Browse files
committed
Add doc comments. Refactor params for consistency.
1 parent 256f558 commit 393f175

File tree

3 files changed

+90
-7
lines changed

3 files changed

+90
-7
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/ChannelDbConnectionPool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void TransactionEnded(Transaction transaction, DbConnectionInternal trans
8080
throw new NotImplementedException();
8181
}
8282

83-
public bool TryGetConnection(DbConnection owningObject, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions, out DbConnectionInternal connection)
83+
public bool TryGetConnection(DbConnection owningObject, TaskCompletionSource<DbConnectionInternal> taskCompletionSource, DbConnectionOptions userOptions, out DbConnectionInternal connection)
8484
{
8585
throw new NotImplementedException();
8686
}

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ internal IDbConnectionPool GetConnectionPool(DbConnectionFactory connectionFacto
189189
IDbConnectionPool newPool;
190190
if (LocalAppContextSwitches.UseConnectionPoolV2)
191191
{
192-
// ChannelDbConnectionPool is the new pool implementation
192+
// ChannelDbConnectionPool is the v2 pool implementation
193193
newPool = new ChannelDbConnectionPool();
194194
}
195195
else
196196
{
197-
// WaitHandleDbConnectionPool is the old pool implementation, and used by default if UseConnectionPoolV2 is off
197+
// WaitHandleDbConnectionPool is the v1 pool implementation, and used by default if UseConnectionPoolV2 is off
198198
newPool = new WaitHandleDbConnectionPool(connectionFactory, this, currentIdentity, connectionPoolProviderInfo);
199199
}
200200

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/IDbConnectionPool.cs

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,54 +13,137 @@
1313
namespace Microsoft.Data.SqlClient.ConnectionPool
1414
{
1515
/// <summary>
16-
/// A base class for implementing database connection pools.
17-
/// Responsible for managing the lifecycle of connections and providing access to database connections.
16+
/// A base interface for implementing database connection pools.
17+
/// Derived classes are responsible for managing the lifecycle
18+
/// of connections and providing access to database connections.
1819
/// </summary>
1920
internal interface IDbConnectionPool
2021
{
2122
#region Properties
23+
/// <summary>
24+
/// An id that uniqely identifies this connection pool.
25+
/// </summary>
2226
int ObjectId { get; }
2327

28+
/// <summary>
29+
/// The current state of the connection pool.
30+
/// </summary>
2431
DbConnectionPoolState State { get; set; }
2532

33+
/// <summary>
34+
/// The number of connections currently managed by the pool.
35+
/// May be larger than the number of connections currently sitting idle in the pool.
36+
/// </summary>
2637
int Count { get; }
2738

39+
/// <summary>
40+
/// Gets the factory used to create database connections.
41+
/// </summary>
2842
DbConnectionFactory ConnectionFactory { get; }
2943

44+
/// <summary>
45+
/// Indicates whether an error has occurred in the pool.
46+
/// Primarily used to support the pool blocking period feature.
47+
/// </summary>
3048
bool ErrorOccurred { get; }
3149

50+
/// <summary>
51+
/// Gets the duration of time to wait before reassigning a connection to a different server in a load-balanced
52+
/// environment.
53+
/// </summary>
3254
TimeSpan LoadBalanceTimeout { get; }
3355

56+
/// <summary>
57+
/// Gets the identity used by the connection pool when establishing connections.
58+
/// </summary>
3459
DbConnectionPoolIdentity Identity { get; }
3560

61+
/// <summary>
62+
/// Indicates whether the connection pool is currently running.
63+
/// </summary>
3664
bool IsRunning { get; }
3765

66+
/// <summary>
67+
/// Gets a reference to the connection pool group that this pool belongs to.
68+
/// </summary>
3869
DbConnectionPoolGroup PoolGroup { get; }
3970

71+
/// <summary>
72+
/// Gets the options for the connection pool group.
73+
/// </summary>
4074
DbConnectionPoolGroupOptions PoolGroupOptions { get; }
4175

76+
/// <summary>
77+
/// Gets the provider information for the connection pool.
78+
/// </summary>
4279
DbConnectionPoolProviderInfo ProviderInfo { get; }
4380

81+
/// <summary>
82+
/// Gets the authentication contexts cached by the pool.
83+
/// </summary>
4484
ConcurrentDictionary<DbConnectionPoolAuthenticationContextKey, DbConnectionPoolAuthenticationContext> AuthenticationContexts { get; }
4585

86+
/// <summary>
87+
/// Indicates whether the connection pool is using load balancing.
88+
/// </summary>
4689
bool UseLoadBalancing { get; }
4790
#endregion
4891

4992
#region Methods
93+
/// <summary>
94+
/// Clears the connection pool, releasing all connections and resetting the state.
95+
/// </summary>
5096
void Clear();
5197

52-
bool TryGetConnection(DbConnection owningObject, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions, out DbConnectionInternal connection);
53-
98+
/// <summary>
99+
/// Attempts to get a connection from the pool.
100+
/// </summary>
101+
/// <param name="owningObject">The SqlConnection that will own this internal connection.</param>
102+
/// <param name="taskCompletionSource">Used when calling this method in an async context.
103+
/// The internal connection will be set on completion source rather than passed out via the out parameter.</param>
104+
/// <param name="userOptions">The user options to use if a new connection must be opened.</param>
105+
/// <param name="connection">The retrieved connection will be passed out via this parameter.</param>
106+
/// <returns>Returns true if a connection was set in the out parameter, otherwise returns false.</returns>
107+
bool TryGetConnection(DbConnection owningObject, TaskCompletionSource<DbConnectionInternal> taskCompletionSource, DbConnectionOptions userOptions, out DbConnectionInternal connection);
108+
109+
/// <summary>
110+
/// Replaces the internal connection currently associated with owningObject with a new internal connection from the pool.
111+
/// </summary>
112+
/// <param name="owningObject">The connection whos internal connection should be replaced.</param>
113+
/// <param name="userOptions">The user options to use if a new connection must be opened.</param>
114+
/// <param name="oldConnection">The internal connection currently associated with the owning object.</param>
115+
/// <returns></returns>
54116
DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection);
55117

118+
/// <summary>
119+
/// Returns an internal connection to the pool.
120+
/// </summary>
121+
/// <param name="obj">The internal connection to return to the pool.</param>
122+
/// <param name="owningObject">The connection that currently owns this internal connection. Used to verify ownership.</param>
56123
void ReturnInternalConnection(DbConnectionInternal obj, object owningObject);
57124

125+
/// <summary>
126+
/// Puts an internal connection from a transacted pool back into the general pool.
127+
/// </summary>
128+
/// <param name="obj">The internal connection to return to the pool.</param>
58129
void PutObjectFromTransactedPool(DbConnectionInternal obj);
59130

131+
/// <summary>
132+
/// Initializes and starts the connection pool. Should be called once when the pool is created.
133+
/// </summary>
60134
void Startup();
61135

136+
/// <summary>
137+
/// Shuts down the connection pool releasing any resources. Should be called once when the pool is no longer needed.
138+
/// </summary>
62139
void Shutdown();
63140

141+
/// <summary>
142+
/// Informs the pool that a transaction has ended. The pool will commit and reset any internal
143+
/// the transacted object associated with this transaction.
144+
/// </summary>
145+
/// <param name="transaction">The transaction that has ended.</param>
146+
/// <param name="transactedObject">The internal connection that should be committed and reset.</param>
64147
void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject);
65148
#endregion
66149
}

0 commit comments

Comments
 (0)