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

[WIP] add server-side C API #2807

Closed
wants to merge 2 commits into from

Conversation

lucifer1004
Copy link

@lucifer1004 lucifer1004 commented Apr 6, 2022

Related to #2797. The API can be called but does not really work yet.

Since I am not yet familiar with the whole project, I would like to hear more advice from the community, especially those who previously worked on the C API.

@lucifer1004
Copy link
Author

@seanmonstar

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this, this looks like a nice start! I left some comments inline to continue the discussion. <3

use super::io::hyper_io;
use super::task::{hyper_executor, hyper_task, WeakExec};

pub struct hyper_http(Http<WeakExec>);
Copy link
Member

Choose a reason for hiding this comment

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

You couldn't know this, but I'm not a fan of the name that's currently Http in hyper. I think this C API type might want to follow the client-side naming, so maybe hyper_serverconn_options? And then similarly with the related functions.

}

type hyper_service_callback =
extern "C" fn(*mut c_void, *mut hyper_request, *mut hyper_response) -> ();
Copy link
Member

Choose a reason for hiding this comment

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

So, it looks like this would require that in C, the callback is synchronous. It must return a response, it can't return a future. I worry that this might make servers in C just do everything in a blocking style, which would be bad for the server.

Would it be hard to have this callback return a *mut hyper_task? I haven't thought too hard about it

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.

2 participants