-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add Rust server and client for get_simple
example
#8
Conversation
Thanks @mbrobbel ! Does the |
It's the recommended approach: |
After reading the guidance on this from the Cargo team, I think I'm -1 on including it in this case. The project here is intended to serve as an example for other projects to build on, not as a standalone project where the top priority is for the binary to build without errors. It seems undesirable in this case to have 900+ extra lines just to ensure the latter. The spirit of this area of the repo is to keep everything very minimal and not have any unnecessary assets even if they are black boxes. |
I tested this Rust server with the clients implemented in other languages. That worked fine. But I ran into problems when I tested this Rust client with the servers implemented in other languages. |
The client works with the Python server example now, but I see errors when I try to use it with the Java and Go server examples. With the Java server, I see this error:
With the Go server, I see this error:
cc @zeroshade |
The problem is caused by the |
Do we want CI? |
Not yet. We will want to add CI later, once the examples like these become part of an official conventions document on the Arrow docs site. I think in general we want to keep this repo free of CI. |
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 tested these with all the other client and server examples and they work as expected. Thanks very much @mbrobbel!
@wjones127 or anyone else watching here: is there anything else you'd like to see here before we merge this?
@mbrobbel I'm curious how feasible it would be to make the client example handle HTTP/1.1 responses with chunked transfer encoding? I think this would just involve handling lines 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.
Thanks @mbrobbel! I re-tested this new version that includes chunked encoding support against all the other server examples, toggling chunked encoding on and off on the servers, and it works as expected.
I will merge later today if there are no other comments. |
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.
Seems okay, though I would definitely prefer it written in something higher-level like hyper. As-is, I'm not sure how many developers would use this logic.
let mut chunked = false; | ||
loop { | ||
let mut line = String::default(); | ||
reader.read_line(&mut line).unwrap(); | ||
if let Some(("transfer-encoding", "chunked")) = line | ||
.to_lowercase() | ||
.split_once(':') | ||
.map(|(key, value)| (key.trim(), value.trim())) | ||
{ | ||
chunked = true; | ||
} | ||
if line == "\r\n" { | ||
break; | ||
} | ||
} |
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.
It feels a bit sad we are manually parsing headers and such. Makes the example a bit harder to follow.
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.
100% agreed. I started with hyper
but moved to std
because of apache/arrow-rs#1207.
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.
Agreed. Of all the examples here, this is the only one that directly implements low-level HTTP details instead of depending on a library to do that.
But the main objective of these get_simple
examples is only to ensure that the IPC implementations in the mainstream Arrow libraries can function and interoperate over HTTP. This achieves that objective.
Co-authored-by: Ian Cook <[email protected]>
FYI with apache/arrow-rs#5531 it should be possible to switch this to use hyper |
A simple synchronous Rust (
std
-based) server and client for theget_simple
example.This skips over all
http
request/response parsing and error handling, but the examples can be updated later to usehyper
(when there is async Arrow IPC support in arrow-rs).