Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jftuga
Copy link
Owner

@jftuga jftuga commented Apr 11, 2025

Purpose

This change refactors the resolveAllDNS function to simplify its concurrency handling.

Changes:

  • Removed the initial concurrency pattern within resolveAllDNS that used a select loop to interleave sending work (workCh) and receiving results (dnsResponseCh).
  • Retained and cleaned up the second pattern (previously using workCh2/dnsResponseCh2, now using the standard workCh/dnsResponseCh names) which follows the simpler and generally more robust "send all work -> close work channel -> receive all results" approach.

Reasoning:

  • The original function contained two distinct and somewhat redundant methods for achieving the same goal.
  • The retained pattern is easier to understand, less complex to manage, and sufficient for this fan-out/fan-in task.
  • This simplification improves the overall readability and maintainability of the function.

No functional changes are expected as a result of this refactoring; it purely streamlines the implementation.

Other small changes

  • Rework function comments
  • check for no results found

@jftuga jftuga force-pushed the bugfix branch 2 times, most recently from 8dfdff3 to 932ca17 Compare April 11, 2025 12:29
@jftuga jftuga changed the title small code improvements Refactor resolveAllDNS Concurrency Pattern Apr 11, 2025
Copy link
Owner Author

@jftuga jftuga left a comment

Choose a reason for hiding this comment

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

Reviewed the diff.

@jftuga jftuga merged commit c9c70d9 into master Apr 11, 2025
@jftuga jftuga deleted the bugfix branch April 11, 2025 12:55
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.

2 participants