-
Notifications
You must be signed in to change notification settings - Fork 68
Codebase improvements. #258
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
Codebase improvements. #258
Conversation
kstrafe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. I'm not sure about the Controller aspect. Why not just call it a normal, distinguishable thing? The Controller part is just noise.
|
I'm not entirely happy with |
TimonPost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the concepts introduced in this PR
- A fake socket implementation for our tests
- Separation of the unit tests, because you'r right that they were mixed
A couple of questions
- Is our
Socketrenamed toSocketController? - I am not sure what to think about the Controller/Handler names, in general, those names are bad practice. Because they are to general. But as you said, you need help with this. Mmmm, I do need to think about that a bit.
|
|
|
Build is failing in jenkins, probably due to older clippy version. cargo --version
cargo clippy --version
cargo fmt --versionWhat do you think? |
|
Yea we should have something like that |
Codecov Report
@@ Coverage Diff @@
## master #258 +/- ##
==========================================
+ Coverage 97.6% 97.79% +0.18%
==========================================
Files 26 28 +2
Lines 2796 2673 -123
==========================================
- Hits 2729 2614 -115
+ Misses 67 59 -8
Continue to review full report at Codecov.
|
|
I tried to add new stage "Environment Info" in Jenkinsfile, but it didn't appeared in CI. BTW. |
jstnlef
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks as though this is making Socket a facade and the real implementation lives in SocketController. Given this, maybe SocketImpl or something of the like is more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments in functions should we do them with lower case or capital. There is a lot of inconsistency with that. We should choose one of those. I don't have any blocking comments. And I like the introduced features like the emulated socket.
|
Indeed, lower case vs upper case in function bodies are very similar.
|
|
Don't mind them for now. That can be done in another PR. |
|
This commit addresses a lot of issues.
I feel that the current state is much better now, but there are a few things that I'm not entirely happy with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm alright with this if @TimonPost is alright with it. I am a little leery about too much abstraction but all in all this isn't too bad. Good work.
TimonPost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the introduced abstractions. You've done great work. Lgtm!
This PR doesn't add or remove any existing functionality or tests, it only solves a few issues in a codebase.
SocketandActiveConnections.Socketknow too many details of a connection andActiveConnectionsis basically a "proxy" object. Since a lot of functionality is in aSocket, it's impossible to write continuations, because of the Rust borrowing rules. E.g. to send heartbeat packets, you have to collect them first (heap allocation) and then send them, instead of iterating over packets and sending immediately (no heap allocation).SocketControllerandConnectionControlleris introduced.SocketControllerowns all core components: active connections, connection handler, event sender/receiver, socket sender/receiver. It is connection agnostic, it only stores a list of active connections, but doesn't do any operations on them. It only has one methodmanual_pollthat does something useful: gets packets and events, and pass all connection related actions to aConnectionControlleralong with a connection.ConnectionControllerControls all aspects of the connection and owns only required components to process it:src/net/socket.rs:fragmentation_send_returns_right_sizethis is connection detail, andSocketshouldn't care about packet size or what is "fragmented" packet, etc...ordered_16_bit_overflowalso a connection detail. More importantly, since it is computation heavy it takes ~11sec on my machine to run it, because of the overhead by testing throughSocketinterface instead of testing directly.In order to make a majority of tests a unit tests, few traits were introduced:
SocketSenderandSocketReceiverand by using these traitsSocketControllerandConnectionControllerbecame socket type agnostic. So actual changes involved:test/basic_socket_test.rs.VirtualConnectionbecause they were more related to an actual connection.BREAKING CHANGES:
set_link_conditionerfromSocket. It doesn't make sense to provide this test function in public API. Why would any sane user need to drop some random packets?Although this looks like a big PR, it actually reduced the number of relevant code. By moving different parts to different places, it allowed writing cleaner code.
This is the last PR to prepare for #246 integration.
EDIT
A lot of changes were made during the process