AspNetCore.Diagnostics.HealthChecks icon indicating copy to clipboard operation
AspNetCore.Diagnostics.HealthChecks copied to clipboard

feat: Expected content on UriHealthCheck

Open benmccallum opened this issue 6 years ago • 17 comments

Addresses my idea in #245

benmccallum avatar Jul 30 '19 03:07 benmccallum

Hi @benmccallum

Build is not working for this PR!

unaizorrilla avatar Jul 30 '19 12:07 unaizorrilla

bump

benmccallum avatar Aug 06 '19 23:08 benmccallum

I’m on vacation these days! Let me check when come back

unaizorrilla avatar Aug 07 '19 06:08 unaizorrilla

No worries, of course! Enjoy your holiday :)

benmccallum avatar Aug 07 '19 22:08 benmccallum

Hey @unaizorrilla , are you back from holidays? I'd like to get this through so that my team can do some work off the back of it.

benmccallum avatar Sep 12 '19 15:09 benmccallum

Yeah! Tomorrow I try to spend all day in healthchecks, 3.0 migration history and pending pr

unaizorrilla avatar Sep 12 '19 15:09 unaizorrilla

Hey @unaizorrilla, the idea behind the Func<HttpContent, (IsOk, Reason)> is that it enables much more powerful checking scenarios.

Consumers could provide their own Func that accepts HttpContent, and they can use all of the available extension methods off HttpContent like .ReadAsAync<T>() to read out strong types, etc. etc., perform their validation and then also return the reason it failed, which will come out in the HealthCheckResult (another reason for the split ifs).

I definitely agree that a tuple is a bad choice for a public API, I'm more than happy to refactor that, but I'm worried about removing the other functionality as I can see powerful uses for it.

benmccallum avatar Sep 24 '19 08:09 benmccallum

Hi @benmccallum

Well, we can accept two overloads with expectedContent and the lambda but please, remove tuples for public api.

Note: Be carefull because we are migrating to netcoreapp3 and modifying branch version.

If healthcheck is for netcoreapp2 please use 2.2 branch, if is for netcoreapp3 use master branch!!

unaizorrilla avatar Sep 24 '19 08:09 unaizorrilla

Hey @unaizorrilla, I've made some changes to the PR to address your concerns, specifically around the option to check the expected content with a Func. The signature is now Func<HttpContent, Task<ContentCheckResult>>. I thought about using a Func<HttpContent, string> and if the string is non-null it's a failure message and the health check should fail, but it seemed too "loose".

I'd gone down that path and described it in the param's description, but in the end went for a typed result, kinda like how MVC does it with ActionResult.

Hope that's OK. Happy to just merge this into master and have it 3.0+. Ready when you are!

benmccallum avatar Oct 14 '19 14:10 benmccallum

bump

benmccallum avatar Nov 06 '19 22:11 benmccallum

bump

benmccallum avatar Nov 16 '19 16:11 benmccallum

Hey @unaizorrilla , sorry to be a pain, I know you're probably super busy, but could we get this merged?

benmccallum avatar Nov 27 '19 11:11 benmccallum

@anthonykeller79, I think we're going to have to just cut out the code into our own code base that we need for this as I'm not sure if this will ever be merged. Unless you wanna fork this into our own org on GitHub and setup a nuget package for it?

benmccallum avatar Dec 31 '19 13:12 benmccallum

@benmccallum Hi. I help maintaining this repo. Rebase onto master if you want to continue working with this PR and I'll review it.

sungam3r avatar Feb 27 '22 00:02 sungam3r

@benmccallum do you need help to finish this pull request? Because I would love to see a completion of this as well, and could potentially take over if you need it.

Nisden avatar Mar 17 '22 08:03 Nisden

Hey @sungam3r and @Nisden , feel free to take over.

It's been so long since I did the work on this that I'm out of touch and you'd be just as good to take over as me starting again. What I wanted to achieve is documented in the linked issue.

Happy to review once it's ready.

benmccallum avatar Mar 24 '22 00:03 benmccallum

Rel: #1199

sungam3r avatar May 30 '22 05:05 sungam3r

I'm closing this one in favor of #1199. For anyone interested in - as @benmccallum said

feel free to take over.

sungam3r avatar Nov 07 '22 20:11 sungam3r