-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
refactor Echo server startup to allow data race free access to listener address #1735
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
refactor Echo server startup to allow data race free access to listener address #1735
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1735 +/- ##
==========================================
+ Coverage 85.87% 86.66% +0.79%
==========================================
Files 29 29
Lines 2018 2063 +45
==========================================
+ Hits 1733 1788 +55
+ Misses 180 175 -5
+ Partials 105 100 -5
Continue to review full report at Codecov.
|
There already where some questions request to know when echo startup is completed. If we need to change interfaces or documented functions for startup we should wait for v5, but the current proposal works with external changes so far. |
ccd9107
to
49aeecb
Compare
49aeecb
to
734e313
Compare
I did not intend to change API in breakable way. Added only 2 methods But for future (v5+) maybe there should be task/issue to investigate/refactor Echo internals a little. For example:
|
Agreed. If we can prepare the infrastructure without modifying the interface we can merge it for v4. @aldas As you did all the preliminary work maybe it makes sense that you open the v5 issue too (if you want).
For an external interface using channels is not encouraged, so I guess we should also use callback functions here to wrap the channel. Seems like this is easier to understand and is in line with our other handlers. |
Test runtime is reduced from ~2.9s to ~0.6s now. Before:
Now (with this PR):
This PR is going to be merged now. A follow up for v5 will be created. Thanks @aldas |
Refactor Echo server startup to allow data race free access to listener address.
This is problem that I have had with one of my apps - it is hard to create FAST test that spins up echo server and does minimal waiting for it. Problem is that to see if server is up and to use it you need to know on what port its listener was bind. but server startup and checking are done in different goroutines as serve start is blocking function call and when you try to acces listener you will have data race failure.
another problem - there are plenty of tests in echo that are doing 200ms waits for server startup and this adds up (about ~2sec excess at the moment)
NB: Echo has many methods to start server. Two instances of listener and server but only one is used when running server - it is confusing.
@lammel @pafuent what are your thoughts? maybe someone has better/cleaner ideas for tests/data race
note: work in progress