Skip to content
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 OracleManagedDataAccess Aspire Component #1004

Closed
wants to merge 3 commits into from

Conversation

andrevlins
Copy link
Contributor

@andrevlins andrevlins commented Nov 23, 2023

Adds the ability to connect to an Oracle database through the OracleManagedDataAccess library by adding a connection of type OracleConnection or DbConnection.

It also adds the ability to configure a container with an Oracle Database Free image (container-registry.oracle.com/database/free:latest).

To continue this work I need the following packages to be available in the nuget repository of this project:

AspNetCore.HealthChecks.Oracle 7.0.0
Oracle.ManagedDataAccess.Core 23.3.0-dev
Oracle.ManagedDataAccess.OpenTelemetry 23.2.0-dev

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-components Issues pertaining to Aspire Component packages label Nov 23, 2023
@andrevlins
Copy link
Contributor Author

Hello @RussKie, Can you help me with these packages mentioned above?

AspNetCore.HealthChecks.Oracle 7.0.0
Oracle.ManagedDataAccess.Core 23.3.0-dev
Oracle.ManagedDataAccess.OpenTelemetry 23.2.0-dev

{
ValidateConnection();

return new OracleConnection(settings.ConnectionString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oracle doesn't have a data source?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I intend to update this code as soon as they implement DbDataSource.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// <param name="builder">The <see cref="IHostApplicationBuilder" /> to read config from and add services to.</param>
/// <param name="connectionName">A name used to retrieve the connection string from the ConnectionStrings configuration section.</param>
/// <param name="configureSettings">An optional delegate that can be used for customizing options. It's invoked after the settings are read from the configuration.</param>
/// <remarks>Reads the configuration from "Aspire:Oracle" section.</remarks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aspire:OracleManagedDataAccess

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to Aspire:Oracle:ManagedDataAccess:Core as @eerhardt advised


public class AspireOracleManagedDataAccessExtensionsTests
{
private const string ConnectionString = "user id=system;password=123;data source=localhost:1522/freepdb1";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a well known connection string?

@eerhardt eerhardt self-assigned this Nov 27, 2023
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project/folder/package name should be Aspire.Oracle.ManagedDataAccess.Core.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I ended up closing the PR unintentionally during this process, sorry about that

using Oracle.ManagedDataAccess.Client;

namespace Aspire.OracleManagedDataAccess;
internal sealed class OracleHealthCheck : IHealthCheck
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Directory.Packages.props Show resolved Hide resolved
/// </summary>
public static class AspireOracleManagedDataAccessExtensions
{
private const string DefaultConfigSectionName = "Aspire:OracleManagedDataAccess";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private const string DefaultConfigSectionName = "Aspire:OracleManagedDataAccess";
private const string DefaultConfigSectionName = "Aspire:Oracle:ManagedDataAccess:Core";

This should follow the name of the component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

if (serviceKey is null)
{
// delay validating the ConnectionString until the DataSource is requested. This ensures an exception doesn't happen until a Logger is established.
builder.Services.AddTransient((serviceProvider) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connection should be transient? I would have guessed scoped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, in this case it really is better for the connection to be scoped

Comment on lines 26 to 32
public bool Tracing { get; set; } = true;

/// <summary>
/// <para>Gets or sets a boolean value that indicates whether the Open Telemetry metrics are enabled or not.</para>
/// <para>Enabled by default.</para>
/// </summary>
public bool Metrics { get; set; } = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these used? If not, we shouldn't have properties for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed for now, I looked in the ODP.NET documentation and there are still no metrics that we can use here.

@@ -0,0 +1,34 @@
{
"properties": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there integration with Logging? If so, can we add the log categories to the ConfigurationSchema.json?

See #430 for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for the time being. I believe that if they implement DbDataSource they will provide this feature.

FYI: oracle/dotnet-db-samples#329

@mitchdenny
Copy link
Member

@andrevlins did you mean to close this?

@smitpatel
Copy link
Member

Force push erased all the commits which were here so github closed the PR. 😟

@andrevlins
Copy link
Contributor Author

@mitchdenny I'll reopen with the new folder structure

@andrevlins andrevlins reopened this Nov 29, 2023
@joperezr joperezr added the community-contribution Indicates that the PR has been added by a community member label Dec 11, 2023
@eerhardt
Copy link
Member

@andrevlins - this PR is marked as a Draft. Is it ready for review?

@andrevlins
Copy link
Contributor Author

@andrevlins - this PR is marked as a Draft. Is it ready for review?

This PR depends on a version of the Oracle.ManagedDataAccess nuget package that is still in preview.
The main reason is that it is the version that supports Open Telemetry.

#1004 (comment)

@eerhardt
Copy link
Member

@andrevlins - do you have a timeline for when you think this PR will be ready for review?

@andrevlins
Copy link
Contributor Author

do you have a timeline for when you think this PR will be ready for review?

I am waiting for the stable version of the library Oracle.ManagedDataAccess.Core and Oracle.ManagedDataAccess.OpenTelemetry version 23.x.x due to OpenTelemetry support.

Some paths we can follow:

  • Continue with the PR in draft until the release of version 23.x.x.
  • Use the ```dev```` version and post the PR for review (I don't think working with unstable versions is viable in this project).
  • Downgrade the version to 3.21.xxx and not support OpenTelemetry (leaving this for another PR once the version is released).
  • Close the PR so as not to disturb your management and open it again when the version is released.

What do you think?

@eerhardt
Copy link
Member

I'm inclined to say that if no progress is being made on this PR, let's close it for now. We can always re-open it when progress is ready to be made.

@andrevlins
Copy link
Contributor Author

I'm inclined to say that if no progress is being made on this PR, let's close it for now. We can always re-open it when progress is ready to be made.

I'll do it this way then

@andrevlins andrevlins closed this Jan 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-components Issues pertaining to Aspire Component packages community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants