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 Dns Resolve Host Count HealthCheck #684 #686

Merged
merged 3 commits into from
Dec 1, 2020

Conversation

CarlosLanderas
Copy link
Contributor

@CarlosLanderas CarlosLanderas commented Nov 24, 2020

Added new DNS healthchecks in Network package to allow configuring a target host and the minimum and maximum IP addresses that should be resolved for that host name.

services
 .AddHealthChecks()
 .AddDnsResolveHostCountHealthCheck(setup =>
  {
     setup.AddHost("yourdomain.com", minHosts: 1, maxHosts: 3);
     setup.AddHost("otherdomain.com", minHosts: 1, maxHosts: 1);
  });

What this PR does / why we need it:

Which issue(s) this PR fixes: #684

Please reference the issue this PR will close: #[issue number]

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Unit tests passing
  • End-to-end tests passing
  • Extended the documentation
  • Provided sample for the feature

@bakgerman
Copy link

yes that looks great!

@bakgerman
Copy link

So, if we don't care about max, only min, we could put MAX_INT as the value...or we could make max_hosts a nullable int, etc...

@CarlosLanderas
Copy link
Contributor Author

CarlosLanderas commented Nov 25, 2020

@bakgerman changed.

Signature:

  public DnsResolveCountOptions AddHost(string hostName, int minHosts, int? maxHosts)
   {
       if (!HostRegistrations.TryGetValue(hostName, out var _))
       {
         HostRegistrations.Add(hostName, (minHosts, maxHosts));
       }

       return this;
    }

Check:

 if (totalAddresses < minHosts || (maxHosts.HasValue && totalAddresses > maxHosts.Value))
 {
   failedResolutions.Add((entry.Key, totalAddresses));
 }

@CarlosLanderas CarlosLanderas self-assigned this Nov 26, 2020



if (totalAddresses < minHosts || (maxHosts.HasValue && totalAddresses > maxHosts.Value))
Copy link
Collaborator

@sungam3r sungam3r Nov 26, 2020

Choose a reason for hiding this comment

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

Suggested change
if (totalAddresses < minHosts || (maxHosts.HasValue && totalAddresses > maxHosts.Value))
if (totalAddresses < minHosts || totalAddresses > maxHosts)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mmm. maxHosts.Value will crash if it has no value?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, my typo, fixed.

@CarlosLanderas CarlosLanderas force-pushed the feature/network-dns-host-count branch from d96b39d to e92b8d9 Compare November 30, 2020 16:12
@CarlosLanderas CarlosLanderas merged commit 2142826 into master Dec 1, 2020
@unaizorrilla unaizorrilla deleted the feature/network-dns-host-count branch October 16, 2021 17:30
@sungam3r sungam3r mentioned this pull request Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants