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

Re-introduce Microsoft.Extensions.ObjectPool.DependencyInjection #4038

Merged
merged 10 commits into from
Jun 16, 2023

Conversation

sebastienros
Copy link
Member

@sebastienros sebastienros commented Jun 7, 2023

null

Microsoft Reviewers: Open in CodeFlow

@ghost ghost assigned sebastienros Jun 7, 2023
@sebastienros
Copy link
Member Author

This is accounting for the aspnetcore api-review (method names, namespaces, api)

@RussKie
Copy link
Member

RussKie commented Jun 8, 2023

Once this is merged please make an update in https://github.com/dotnet/api-catalog-infra/ - either update https://github.com/dotnet/api-catalog-infra/pull/59 (if it's still unmerged) or apply the renaming separately.

/// </summary>
[Experimental]
public static class ObjectPoolServiceCollectionExtensions
{
Copy link
Member

Choose a reason for hiding this comment

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

Can we get back the overload that consumes a configuration section? We want to systematically enable things to be configured in this way and it's the convention in this repo.

Can we call all the configuration delegate just "configure" which is the convention we use in this repo?

Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently looking into why the section was removed after aspnetcore api-review, they had some arguments that might be worth checking.

configureOptions: there are a few occurrences in this repos in case you think it's worth going through the rest of the code for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

@geeknoid This is like a custom deserialization for these settings. I see that it's checking the value is a valid integer, what else is it providing over the standard configuration methods?

Copy link
Member

Choose a reason for hiding this comment

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

So yes, we should change "configureOptions" to "configure" for general consistency.

Within this repo, we generally use a triplet of functions for configuring components. No options (you get the defaults), an Action delegate which lets you override options, and a ConfigurationSection to make it easy to consume the configuration state from an external JSON. This model has been working well for us.

@tekian Jan helped establish this pattern 3 years ago or so, maybe he has additional insights to provide.

Copy link
Contributor

Choose a reason for hiding this comment

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

With respect to configuration section, we make no assumptions about where in the configuration hierarchy is the section to configure the component. We let developer decide and hand us the section to bind to. IConfigurationSection, as compared to IConfiguration, knows Path which was an information we wanted to capture to be able to reconstruct configuration schema.

Copy link
Member

Choose a reason for hiding this comment

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

Thats fine but 90% of our code takes IConfiguration, not IConfigurationSection and it usually parses a known schema (more than just an int). The pattern should be consistent with the rest of the APIs in the stack.

# Conflicts:
#	src/ToBeMoved/DependencyInjection.Pools/DependencyInjectionExtensions.cs
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Extensions.DependencyInjection.Pools;
namespace Microsoft.Extensions.ObjectPool;

/// <summary>
/// Contains configuration for pools.
/// </summary>
[Experimental]
public sealed class PoolOptions
Copy link
Member

Choose a reason for hiding this comment

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

Given that this is now in the general-purpose Microsoft.Extensions.ObjectPool namespace, perhaps we should give this a more specialized name? ServiceCollectionPoolOptions maybe? Any other ideas?

Copy link
Member Author

Choose a reason for hiding this comment

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

This one is hard, DependencyInjectionPoolOptions? But the current name loks fine to me, there is no conflict and users will probably not use the class name directly.

Copy link
Member

Choose a reason for hiding this comment

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

Why didn't this get called ObjectPoolOptions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Martin. It looks strange, that this type (or ObjectPoolOptions) is not used by Microsoft.Extensions.ObjectPool || Microsoft.Extensions.ObjectPool<T>.

@RussKie
Copy link
Member

RussKie commented Jun 15, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sebastienros
Copy link
Member Author

@RussKie flaky tests? also the Tests tab is empty on azdo, the one listing all failed tests and artifacts.

@RussKie
Copy link
Member

RussKie commented Jun 15, 2023

@RussKie Igor Velikorossov FTE flaky tests? also the Tests tab is empty on azdo, the one listing all failed tests and artifacts.

I believe this is caused by #4078. I have a hunch Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test could be unsettling the build agent - I saw a few build runs where tests from that project failed.

@RussKie
Copy link
Member

RussKie commented Jun 16, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@RussKie
Copy link
Member

RussKie commented Jun 16, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sebastienros sebastienros merged commit 79baf4a into main Jun 16, 2023
@sebastienros sebastienros deleted the sebros/pool branch June 16, 2023 20:39
@ghost ghost added this to the 8.0 Preview6 milestone Jun 16, 2023
@RussKie
Copy link
Member

RussKie commented Jun 19, 2023

@sebastienros please don't forget about #4038 (comment).

@ghost ghost locked as resolved and limited conversation to collaborators Jul 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants