Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/graceful/net_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,13 @@ func CloseProvidedListeners() error {
return returnableError
}

var GetListener = DefaultGetListener
Copy link
Contributor

Choose a reason for hiding this comment

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

It needs some comments about why it is done so here.

Otherwise it looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Primary reason for it being there is because that is where the GetListener function was before and I was trying to avoid moving anything or otherwise avoid making changes that would be cosmetic or unnecessary. Putting it there kept the whole set of changes to just the 2 lines and makes it very clear that all I did was make a function replaceable. I could move the GetListener variable declaration to the top of the file and it would have the same effect obviously, and if that's preferred I will.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the GetListener to the top of the file with the other vars, commented both GetListener and DefaultGetListener to explain their usage, and added a GetListener/DefaultGetListener pair to net_windows.go


// GetListener obtains a listener for the local network address. The network must be
// a stream-oriented network: "tcp", "tcp4", "tcp6", "unix" or "unixpacket". It
// returns an provided net.Listener for the matching network and address, or
// creates a new one using net.Listen.
func GetListener(network, address string) (net.Listener, error) {
func DefaultGetListener(network, address string) (net.Listener, error) {
// Add a deferral to say that we've tried to grab a listener
defer GetManager().InformCleanup()
switch network {
Expand Down