Repository navigation
Add a pooling data source #2635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e6c3914
Class skeleton
mdaigle 67507a9
Add pooling internals and docs. Add return method to data source inte…
mdaigle faa5ab9
Pull feature branch
mdaigle fc93868
Add async param to data source return. Add open internal method to da…
mdaigle d9d77f2
Undo cs proj change.
mdaigle d3ac251
Adjust return flow. Make connector methods internal.
mdaigle f7b1185
Change order of return and owning connection reference drop.
mdaigle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/PoolingDataSource.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| #if NET8_0_OR_GREATER | ||
|
|
||
| using System; | ||
| using System.Collections.Concurrent; | ||
| using System.Net.Security; | ||
| using System.Security.Cryptography.X509Certificates; | ||
| using System.Threading; | ||
| using System.Threading.Channels; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Data.ProviderBase; | ||
| using Microsoft.Data.SqlClient; | ||
|
|
||
| namespace Microsoft.Data.SqlClientX | ||
| { | ||
| /// <summary> | ||
| /// A pooling implementation of SqlDataSource. Connections are recycled upon return to be reused by another operation. | ||
| /// </summary> | ||
| internal sealed class PoolingDataSource : SqlDataSource | ||
| { | ||
| private DbConnectionPoolGroupOptions _connectionPoolGroupOptions; | ||
|
|
||
| internal int MinPoolSize => _connectionPoolGroupOptions.MinPoolSize; | ||
| internal int MaxPoolSize => _connectionPoolGroupOptions.MaxPoolSize; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new PoolingDataSource. | ||
| /// </summary> | ||
| //TODO: support auth contexts and provider info | ||
| PoolingDataSource(SqlConnectionStringBuilder connectionStringBuilder, | ||
| SqlCredential credential, | ||
| RemoteCertificateValidationCallback userCertificateValidationCallback, | ||
| Action<X509CertificateCollection> clientCertificatesCallback, | ||
| DbConnectionPoolGroupOptions options) : base(connectionStringBuilder, credential, userCertificateValidationCallback, clientCertificatesCallback) | ||
| { | ||
| _connectionPoolGroupOptions = options; | ||
| //TODO: other construction | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| internal override ValueTask<SqlConnector> GetInternalConnection(SqlConnectionX owningConnection, TimeSpan timeout, bool async, CancellationToken cancellationToken) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| internal override ValueTask<SqlConnector> OpenNewInternalConnection(SqlConnectionX owningConnection, TimeSpan timeout, bool async, CancellationToken cancellationToken) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| internal override ValueTask ReturnInternalConnection(bool async, SqlConnector connection) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Closes extra idle connections. | ||
| /// </summary> | ||
| /// <exception cref="NotImplementedException"></exception> | ||
| internal void PruneIdleConnections() | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Warms up the pool to bring it up to min pool size. | ||
| /// </summary> | ||
| /// <exception cref="NotImplementedException"></exception> | ||
| internal void WarmUp() | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these callbacks exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a holdover from npgsql inspiration. I can clean them up and come back around later as the auth flows are fleshed out.