Skip to content
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

Rewrite client and server using reqwest and axum #1429

Merged
merged 4 commits into from
Jan 1, 2024
Merged

Rewrite client and server using reqwest and axum #1429

merged 4 commits into from
Jan 1, 2024

Conversation

ayush-sb
Copy link
Contributor

Pull Request

This PR is to upgrade the network module to hyper 1.1.0.

As mentioned in #1421, hyper 1.1.0 has had many breaking changes. The Client struct no longer exists, and requests are now made by a SendRequest which has a different implementation for HTTP1 and HTTP2. However, this is quite low-level for our needs. Initialization of a SendRequest object also requires a handshake which causes issues like initialization becoming async, resulting in having to make fn default() and other such methods async. Also, some exchanges only support HTTP1, but the HTTP1 SendRequest struct is not cloneable at the moment.

For now, reqwest provides a very similar Client object, with roughly the same functionality. It is also cloneable. Another option is moving to the legacy Client in the hyper-util crate. However, reqwest seems to do the job for now, and we can stay with it until there are some more changes to hyper that make it easier to implement for our needs.

@ayush-sb ayush-sb marked this pull request as draft December 29, 2023 10:01
@ayush-sb
Copy link
Contributor Author

The currently implemented reqwest client passes all existing tests. The next step is to rewrite the test server using hyper 1.1.0 and update all the tests.

@ayush-sb
Copy link
Contributor Author

ayush-sb commented Jan 1, 2024

The hyper upgrade has also caused breaking changes for servers, such as the removal of Server struct and moving towards a lower-level interface in general. The hyper-util crate also does not provide any legacy Server implementation.

axum provides a simple implementation for servers which is sufficient for our needs. While this is a comparatively heavier dependency, it's kept as a dev dependency as it's only used for tests. Moreover it simplifies the test code a lot. If there are any performance issues down the line, the server can be rewritten using a different crate such as warp or tower-hyper.

@ayush-sb ayush-sb changed the title Upgrade to hyper 1.1.0 Rewrite client and server using reqwest and axom Jan 1, 2024
@ayush-sb ayush-sb marked this pull request as ready for review January 1, 2024 10:58
@twitu twitu linked an issue Jan 1, 2024 that may be closed by this pull request
Copy link
Collaborator

@twitu twitu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reqwest appears to provide a much cleaner abstraction! Looks good to go 🚀 .

@cjdsellers cjdsellers changed the title Rewrite client and server using reqwest and axom Rewrite client and server using reqwest and axum Jan 1, 2024
@cjdsellers cjdsellers merged commit ccdd4dc into nautechsystems:develop Jan 1, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade hyper dependency to 1.1.0
3 participants