atc0005 / dnsc

Run a DNS query concurrently against all servers in a list and provide results summary
MIT License
7 stars 0 forks source link

Modify DNS server loop to close results channel #19

Closed atc0005 closed 3 years ago

atc0005 commented 4 years ago

Currently we are using a different approach to tell when all DNS server queries have completed. Closing the channel as the last DNS servers range iteration should be easier to manage?

Insert point looks like line 88:

https://github.com/atc0005/dnsc/blob/ef69f557d3730f3f8bad6229fdb1213bf2209c63/cmd/dnsc/main.go#L86-L90

atc0005 commented 4 years ago

Printed page 5 of 8:

The range will work until the channel is closed explicitly.

https://guzalexander.com/2013/12/06/golang-channels-tutorial.html

They're using a dedicated book done channel, returns zero value upon channel close. Will have to keep that bit in mind.

atc0005 commented 4 years ago

Closing the channel as the last DNS servers range iteration should be easier to manage?

Except if we close the channel, how will any slow goroutine respond on the results channel?

atc0005 commented 4 years ago

https://dave.cheney.net/2013/04/30/curious-channels

Using this property we can rewrite the program, now including 100 routines, without having to keep track of the number of goroutines spawned, or correctly size the finish channel.

sync.WaitGroup, finish channel, close finish channel to trigger calling done.Done()

atc0005 commented 3 years ago

Resolved as part of #145.