-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Change HBRequest/HBResponse to struct #96
Conversation
Codecov Report
@@ Coverage Diff @@
## main #96 +/- ##
==========================================
+ Coverage 82.40% 82.57% +0.16%
==========================================
Files 53 53
Lines 2574 2599 +25
==========================================
+ Hits 2121 2146 +25
Misses 453 453
Continue to review full report at Codecov.
|
store static internals as a class to reduce amount of data copied about
a664fbd
to
22d43a2
Compare
@mcritz do you have any thoughts on this? Would like to get other people to have a look before I commit to this |
@adam-fowler I’ll take some time to look into this. My first thought is that if this is a breaking change, then it absolutely means a major version bump. Todo:
|
@adam-fowler I think it works OK. And from an application developer perspective, I suppose its all an implementation detail. But the What specifically is motivating the change? Are these types going to be changed to |
@mcritz The main motivation behind the changes is to avoid race conditions. With The change to a struct does have a performance cost, but by moving all the read only values into the internal class Much of this work has been inspired by the requirements for the |
ffbb544
to
1807683
Compare
1807683
to
e30ac93
Compare
c6fcf5b
to
561d4ba
Compare
Given we haven't gone 1.0 yet, we haven't committed to a interface and don't really need a major bump before releasing this. Swift concurrency may force other changes on us and I don't want to go up to v1.0 prior to that. |
Gotcha! Cool |
Made
HBRequest
andHBResponse
structs. This should make moving to a full async/await implementation a little easier as they become automaticallySendable
as long as all their members areSendable
.For most situations, code changes related to
HBResponse
becoming a struct involves making a mutable instance of the response.It is slightly more complex for
HBRequest
.HBRequest
is large enough such that converting it to astruct
actually reduces performance. To fix this I have moved all the parameters ofHBRequest
that are read only into an internal class. There is no point copying all this data through all the response generators. Storing it in a class means only a reference to the data is passed through.Having
HBRequest
as a struct also means some APIs that would have edited the request have had to change. You can see this in changes to hummingbird-auth