Installation
- .NET CLI
- Package Reference
- Nuget
Defaults
By default, theMySqlDataSource instance is resolved from service provider.
(This should be the same as the instance being used by the application; do not create a new MySqlDataSource just for the health check.)
The health check will send a MySQL “ping” packet to the server to verify connectivity.
Connection String
You can also specify a connection string directly:MySqlDataSource in your application.
Customization
You can additionally add the following parameters:healthQuery: A query to run against the server. Ifnull(the default), the health check will send a MySQL “ping” packet to the server.configure: An action to configure theMySqlConnectionobject. This is called after theMySqlConnectionis created but before the connection is opened.name: The health check name. The default ismysql.failureStatus: TheHealthStatusthat should be reported when the health check fails. Default isHealthStatus.Unhealthy.tags: A list of tags that can be used to filter sets of health checks.timeout: ASystem.TimeSpanrepresenting the timeout of the check.
Breaking changes
In previous versions,MySqlHealthCheck defaulted to testing connectivity by sending a SELECT 1; query to the server.
It has been changed to send a more efficient “ping” packet instead.
To restore the previous behavior, specify healthQuery: "SELECT 1;" when registering the health check.
While not a breaking change, it’s now preferred to use MySqlDataSource instead of a connection string.
This allows the health check to use the same connection pool as the rest of the application.
This can be achieved by calling the .AddMySql() overload that has no required parameters.
The health check assumes that a MySqlDataSource instance has been registered with the service provider and will retrieve it automatically.