-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This differs from the existing StateChanged event in that: - it supports an async callback - it's only invoked when a connection is opened - it provides information about new vs existing and whether the connection was reset Signed-off-by: Bradley Grainger <[email protected]>
- Loading branch information
Showing
10 changed files
with
273 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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,9 @@ | ||
namespace MySqlConnector; | ||
|
||
/// <summary> | ||
/// A callback that is invoked when a new <see cref="MySqlConnection"/> is opened. | ||
/// </summary> | ||
/// <param name="context">A <see cref="MySqlConnectionOpenedContext"/> giving information about the connection being opened.</param> | ||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel the asynchronous operation.</param> | ||
/// <returns>A <see cref="ValueTask"/> representing the result of the possibly-asynchronous operation.</returns> | ||
public delegate ValueTask MySqlConnectionOpenedCallback(MySqlConnectionOpenedContext context, CancellationToken cancellationToken); |
This file contains 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,23 @@ | ||
namespace MySqlConnector; | ||
|
||
/// <summary> | ||
/// Bitflags giving the conditions under which a connection was opened. | ||
/// </summary> | ||
[Flags] | ||
public enum MySqlConnectionOpenedConditions | ||
{ | ||
/// <summary> | ||
/// No specific conditions apply. This value may be used when an existing pooled connection is reused without being reset. | ||
/// </summary> | ||
None = 0, | ||
|
||
/// <summary> | ||
/// A new physical connection to a MySQL Server was opened. This value is mutually exclusive with <see cref="Reset"/>. | ||
/// </summary> | ||
New = 1, | ||
|
||
/// <summary> | ||
/// An existing pooled connection to a MySQL Server was reset. This value is mutually exclusive with <see cref="New"/>. | ||
/// </summary> | ||
Reset = 2, | ||
} |
This file contains 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,23 @@ | ||
namespace MySqlConnector; | ||
|
||
/// <summary> | ||
/// Contains information passed to <see cref="MySqlConnectionOpenedCallback"/> when a new <see cref="MySqlConnection"/> is opened. | ||
/// </summary> | ||
public sealed class MySqlConnectionOpenedContext | ||
{ | ||
/// <summary> | ||
/// The <see cref="MySqlConnection"/> that was opened. | ||
/// </summary> | ||
public MySqlConnection Connection { get; } | ||
|
||
/// <summary> | ||
/// Bitflags giving the conditions under which a connection was opened. | ||
/// </summary> | ||
public MySqlConnectionOpenedConditions Conditions { get; } | ||
|
||
internal MySqlConnectionOpenedContext(MySqlConnection connection, MySqlConnectionOpenedConditions conditions) | ||
{ | ||
Connection = connection; | ||
Conditions = conditions; | ||
} | ||
} |
This file contains 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 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 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
Oops, something went wrong.