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

Reduce the number of clone calls in the gRPC pseudo-node #813

Closed
ipetr0v opened this issue Apr 4, 2020 · 0 comments · Fixed by #838
Closed

Reduce the number of clone calls in the gRPC pseudo-node #813

ipetr0v opened this issue Apr 4, 2020 · 0 comments · Fixed by #838
Assignees

Comments

@ipetr0v
Copy link
Contributor

ipetr0v commented Apr 4, 2020

If I understand correctly - Hyper creates a new instance of a server for each user request.
More than that, it can pass a server generator to other threads that may work with individual user connections.
So we need a make_service_fn that creates an asynchronous server generator used by different threads, and a service_fn function that is used by a thread to generate a server instance to serve each user request (serve is also async).

In order to deal with the Rust borrow checker we need to clone the server 3 times:

let generator_server = server.clone();
let service = hyper::service::make_service_fn(move |_| {
let connection_server = generator_server.clone();
async move {
Ok::<_, hyper::Error>(hyper::service::service_fn(move |req| {
let request_server = connection_server.clone();
async move { request_server.serve(req).await }
}))
}
});

Based on the Slack thread.

@ipetr0v ipetr0v self-assigned this Apr 9, 2020
ipetr0v added a commit that referenced this issue May 5, 2020
This change:
- Adds TLS handling logic to the gRPC pseudo-Node
- Reimplements gRPC processing using Tonic library

Fixes #806
Fixes #813
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant