-
Notifications
You must be signed in to change notification settings - Fork 173
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
Uniform API for custom headers between clients #814
Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
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.
LGTM,
I like this and I have created this PR https://github.com/paritytech/soketto/pull/60/files which changes soketto to use HeaderMap
but I need to benchmark it.
Especially for the client is makes sense as to have this verification as invalid HTTP headers
can't be created.
httparse
is really intended for parsing HTTP headers not create them :P
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
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.
Liking the standardisation! Any idea what the performance impact of this change is?
For the websocket client is should "only" impact the connection speed and we have no benchmarks for that.... On the other hand for the HTTP client the headers are "cloned" for each call which should visible on the benchmarks if we enabled "some custom headers". |
The results of running the benchmarks surprisingly improved performance for some scenarios.
The test runs were performed a few hours apart, without changing the commit head (this one). A few other outliers
That being said, I think we'll get a more reliable read of the benchmarks running the nightly CI. |
The batch benches are really "random", so nothing to with your PR but probably worth to investigate why that is. The HTTP requests could be faster as the actual request headers are "cached" and cloned on each request which wasn't the case before. However, it would be good to add two additional benches:
Feel free to merge this one but I don't think the current benches really matter that much for this PR. |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Jsonrpsee allows users to set custom headers during the WS handshake (for the ws-clients).
This PR extends the ability to add custom headers for the HTTP clients.
The PR introduces a uniform API for the client builders, relying on
http::HeaderMap
that behaves as follows:
One advantage is that the ws-client and http-client have a uniform API, used for caching or any custom user operations, extending jsonrpsee beyond the realm of the
Substrate
.One disadvantage is that ws-client uses
soketto
that internally requires anhttparse::Header
object, which leads to conversion fromhttp::HeaderMap
only if present.Next Steps
Closes #809.