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 overload to HealthChecks for configuring options #25238

Closed
wants to merge 2 commits into from

Conversation

Kahbazi
Copy link
Member

@Kahbazi Kahbazi commented Aug 25, 2020

Fixes #8530

@pranavkm pranavkm added api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews area-healthchecks Includes: Healthchecks (some bugs also in Extensions repo) labels Aug 25, 2020
@ghost
Copy link

ghost commented Aug 25, 2020

Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:

  • The PR contains changes to the reference-assembly that describe the API change. Or, you have included a snippet of reference-assembly-style code that illustrates the API change.
  • The PR describes the impact to users, both positive (useful new APIs) and negative (breaking changes).
  • Someone is assigned to "champion" this change in the meeting, and they understand the impact and design of the change.

throw new ArgumentNullException(nameof(configureOptions));
}

services.AddOptions<HealthCheckServiceOptions>().Configure(configureOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it sufficient to call services.Configure(configureOptions)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a unit test for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a test.

/// <param name="services">The <see cref="IServiceCollection"/> to add the <see cref="HealthCheckService"/> to.</param>
/// <param name="configureOptions">A delegate to configure the <see cref="HealthCheckServiceOptions"/>.</param>
/// <returns>An instance of <see cref="IHealthChecksBuilder"/> from which health checks can be registered.</returns>
public static IHealthChecksBuilder AddHealthChecks<TService>(this IServiceCollection services, Action<HealthCheckServiceOptions, TService> configureOptions) where TService : class
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

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 overload allows to resolve a service from IoC container to configure the options.
Several services now have both overloads. 5a375a7

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem worth adding, the underlying options builder api supports up to 5 services, and it's an uncommon enough scenario that it doesn't seem worth adopting as a general pattern to have all AddXyz methods add this overload. I think we should encourage people who want to configure options with services to do it via optionsbuilder

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this overload.

@Pilchie Pilchie added the community-contribution Indicates that the PR has been added by a community member label Aug 27, 2020
@pranavkm pranavkm added api-needs-work API needs work before it is approved, it is NOT ready for implementation and removed api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Aug 31, 2020
@pranavkm pranavkm added api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews and removed api-needs-work API needs work before it is approved, it is NOT ready for implementation labels Sep 18, 2020
@ghost
Copy link

ghost commented Sep 18, 2020

Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:

  • The PR contains changes to the reference-assembly that describe the API change. Or, you have included a snippet of reference-assembly-style code that illustrates the API change.
  • The PR describes the impact to users, both positive (useful new APIs) and negative (breaking changes).
  • Someone is assigned to "champion" this change in the meeting, and they understand the impact and design of the change.

@pranavkm pranavkm added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Sep 21, 2020
@pranavkm
Copy link
Contributor

@dougbu do we need to do anything to make the PublicAPI files to be regened for this project?

@dougbu
Copy link
Member

dougbu commented Sep 21, 2020

@pranavkm yes, this PR was created before the project even had public API baselines. You'll need to open the project or a containing solution in VS, build and use the analyzer's fixer to add the new API to the baselines. Do not merge before updating because it'll merge cleanly and break every subsequent build.

There's more information in #24347

@pranavkm
Copy link
Contributor

@dougbu I'm having no luck getting the analyzer to complain. Do I need to do enable something for it work?

@dougbu
Copy link
Member

dougbu commented Sep 21, 2020

@dougbu I'm having no luck getting the analyzer to complain. Do I need to do enable something for it work?

Nothing other than the steps I outlined should be necessary once you've built inside Visual Studio and looked at the errors and warnings for RS0016 (think that's the right one)

@pranavkm pranavkm added api-approved API was approved in API review, it can be implemented and removed api-approved API was approved in API review, it can be implemented labels Sep 21, 2020
@weichch
Copy link
Contributor

weichch commented Oct 3, 2020

Frankly, I don't think this PR fixes #8530 and the issue doesn't look valid. #8530 (comment)

@pranavkm
Copy link
Contributor

@weichch you are right. @Kahbazi I'm going to close this since a fix for this is much more different than what's being done here.

@pranavkm pranavkm closed this Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented area-healthchecks Includes: Healthchecks (some bugs also in Extensions repo) 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.

services.AddHealthChecks missing overload that takes delegate for configuring HealthChecksOptions
6 participants