-
Notifications
You must be signed in to change notification settings - Fork 526
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
Add Aspire.MySqlConnector #825
Conversation
Using the component name "Aspire.MySqlConnector" to leave the door open for "Aspire.MySql.Data" (based on the MySql.Data library) in the future.
As per my comment I'd be very happy for Aspire to be "opinionated" about MySQL libraries, and just call this component "Aspire.MySql" instead of "Aspire.MySqlConnector". (MySql.Data doesn't implement |
This is awesome. We should also think about what the AppHost side of things might look like in this PR. For example: var builder = DistributedApplication.CreateBuilder(args);
var mysql = builder.AddMySql("mysql");
var backend = builder.AddProject<Projects.Backend>("backend")
.WithReference(mysql); You can checkout code in |
New packages will need to be mirrored before PR checks can pass I think? |
I'll take care of the mirroring in the morning. @bgrainger - can you also add tests? See
for examples. |
<IsPackable>true</IsPackable> | ||
<PackageTags>$(ComponentDatabasePackageTags) mysqlconnector mysql sql</PackageTags> | ||
<Description>A MySQL client that integrates with Aspire, including health checks, metrics, logging, and telemetry.</Description> | ||
<PackageIconFullPath>$(SharedDir)SQL_256x.png</PackageIconFullPath> |
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.
@DamianEdwards - should this have the same icon as the https://www.nuget.org/packages/MySqlConnector/ package?
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.
That would be ideal, assuming we have permission to do so 😀
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 created the MySqlConnector package icon (using free sources) and will give any necessary permission to include it here.
src/Components/Aspire.MySqlConnector/AspireMySqlConnectorExtensions.cs
Outdated
Show resolved
Hide resolved
|
||
internal static class MySqlConnectorCommon | ||
{ | ||
public static void AddMySqlMetrics(MeterProviderBuilder meterProviderBuilder) |
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'm not sure we need this given we only have 1 component. Is there an EntityFramework "MySqlConnector" library?
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.
The EF Core library built on top of MySqlConnector is https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql.
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'm happy to add support for that too, but will probably do it as a separate PR.
FYI @ajcvickers @roji for awareness of more data related Aspire packages... |
@bgrainger I've just had a look through the AppModel side of the PR and everything looks in order (great work!). |
Great to see this @bgrainger! After this we can also add the Pomelo EF provider for MySQL (/cc @lauxjpn).
On this... Unlike the situation with SQL Server and PostgreSQL, where there really is basically only one (main) driver (SqlClient and Npgsql respectively), with MySql there really are two - the community MySqlConnector being wrapped here (with the Pomelo EF connector built on top of it) and the "official" providers from Oracle. I'm definitely a big supporter of the former pair - and also of the idea of being opinionated in Aspire - but I think we should continue to include the driver name here (i.e. Aspire.MySqlConnector rather than Aspire.MySql). Note that even for Npgsql we have Aspire.Npgsql (rather than Aspire.PostgreSQL). |
I'm planning to come back and add Pomelo EF support, but will probably do that as a separate PR. |
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.
@DamianEdwards do we need perms to include this
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'll revert this, to avoid any possible problems over asset permissions.
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.
From my reading, we'd need written permission to use the logo. I can work offline to enquire about that.
Added |
/azp run dotnet.aspire |
Pull request contains merge conflicts. |
Conflicts: Directory.Packages.props
It'd be great to have a MySql sample (in https://github.com/dotnet/aspire-samples) once this is in, if you're interested in that followup. |
Maybe we should leave the logo out for now, so we're not waiting on Damian to talk to Oracle. |
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.
This is looking really great! Thank you for your contribution, @bgrainger. (and on the first day we made the repo public 😄.
I just have a few comments.
Regarding the name of the component. What you have in your current code is correct. See the policy at:
aspire/src/Components/README.md
Lines 5 to 8 in ab931f0
## Naming | |
- Each component's name should contain just an `Aspire.` prefix. | |
- When component is built around `ABC` client library, it should contain the client library name in its name. Example: `Aspire.ABC`. |
Since this component is built around MySqlConnector
, the correct name for it is Aspire.MySqlConnector
.
<TargetFramework>$(NetCurrent)</TargetFramework> | ||
<IsPackable>true</IsPackable> | ||
<PackageTags>$(ComponentDatabasePackageTags) mysqlconnector mysql sql</PackageTags> | ||
<Description>A MySQL client that integrates with Aspire, including health checks, metrics, logging, and telemetry.</Description> |
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.
Does MySQL need a ®
sign after it, like we do for PostgreSQL?
ConnectionString = serviceKey is null | ||
? sp.GetRequiredService<MySqlDataSource>().ConnectionString | ||
: sp.GetRequiredKeyedService<MySqlDataSource>(serviceKey).ConnectionString |
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.
How do you feel about opening a PR to https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks to make this consistent with Npgsql? We shouldn't be creating another DbDataSource and checking the health of that. Instead, we should be using the same DbDataSource instance as the app is using. That way if that DbDataSource ever gets corrupt, the health check is accurate. From the Components README:
aspire/src/Components/README.md
Line 68 in ab931f0
- Consider whether the Health Check should reuse the same client object registered in DI by the component or not. Reusing the same client object has the advantages of getting the same configuration, logging, etc during the health check. |
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.
Sounds good; I have another reason to open a PR there, too: Xabaril/AspNetCore.Diagnostics.HealthChecks#2031.
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.
All requirements are met except for public API review.
src/Components/Aspire.MySqlConnector/AspireMySqlConnectorExtensions.cs
Outdated
Show resolved
Hide resolved
This allows us to use the built-in support for keyed services.
} | ||
else | ||
{ | ||
throw new DistributedApplicationException("Parent resource connection string was null."); |
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.
@eerhardt should we start moving these things to a resx? I assume we won't localize unless the base libraries start to localize. So perhaps there isn't much value.
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.
ASP.NET Core doesn't have a lot of its exception messages in resx's either. For example
If we ever needed to localize our exceptions, it wouldn't be that hard to find these. But odds are, after 8 years of .NET Core System.* libraries not being localized, I'd be surprised if it ever happens.
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.
Agreed.
Needs |
I kicked that, should be about 10 minutes. |
the package was mirrored and the build succeeds. |
Conflicts: Directory.Packages.props
@bgrainger - any reason this is in "Draft"? I didn't see a reason it was marked draft. |
Put it in draft while I waited to update to MySqlConnector 2.3.1; ready for review now. |
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.
This looks great. Thanks again, @bgrainger! The unresolved comments can be addressed in follow up PRs. I think this is ready to be merged.
I'll wait until EOD before mering this, to allow for any additional feedback from other reviewers.
Amazing 🚀 |
Using the component name "Aspire.MySqlConnector" to leave the door open for "Aspire.MySql.Data" (based on the MySql.Data library) in the future.
Fixes #786