add ListenConfigControl option to Listener#802
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (53.33%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #802 +/- ##
==========================================
- Coverage 82.57% 82.47% -0.10%
==========================================
Files 116 116
Lines 6650 6664 +14
==========================================
+ Hits 5491 5496 +5
- Misses 760 767 +7
- Partials 399 401 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
config.go
Outdated
| OnConnectionAttempt func(net.Addr) error | ||
|
|
||
| // Control function used by net.ListenConfig to create the underlying listener socket. | ||
| ListenConfigControl func(network, address string, c syscall.RawConn) error |
There was a problem hiding this comment.
Config will be deprecated. I suggest removing this, we now prefer the options-based APIs (*WithOptions).
There was a problem hiding this comment.
I have made this field private, *WithOptions still relies on this Config struct internally
JoTurk
left a comment
There was a problem hiding this comment.
Thank you so much for doing this fast :)
other than fixing the lint we require that all PRs include a test even if a simple one, we should just add a simple one to make sure that we don't break this in the future.
config.go
Outdated
| OnConnectionAttempt func(net.Addr) error | ||
|
|
||
| // Control function used by net.ListenConfig to create the underlying listener socket. | ||
| ListenConfigControl func(network, address string, c syscall.RawConn) error |
There was a problem hiding this comment.
I think we should do like you suggested initially in discord with ListenConfig not just control.
There was a problem hiding this comment.
I have replied below, please let me know if that makes sense and I will change accordingly!
|
@theodorsm the reason for this was discussed on discord https://discord.com/channels/1352636971591274548/1359189787768258671/1473686824701661277 |
|
For additional flexibility, why not do edit: I see JoTurk suggested it above as well. |
@adrianosela this is exactly what we agreed on in discord before making this PR, I'm curious if there a reason for going with control instead :) |
Indeed this is what we agreed on and this is what I started implementing but then I realized that I thought it would be messy to embed |
247b618 to
8433e53
Compare
|
I still think the whole object is a better idea. I think its unfortunate that I'm honestly not sure what's best here, but I'm not a fan of passing only Control. Any thoughts @JoTurk , @theodorsm ? If you guys are happy with this in its current state, I don't object to it going in. |
Description
Add an optional option to apply socket configurations before socket binding.
Tested locally (PASSED) with PORT_REUSE option.