-
Notifications
You must be signed in to change notification settings - Fork 45
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 example of a porting library #99
Comments
This is an interesting idea! When you say "porting" do you mean an example of writing Neon/Node bindings to an existing Rust crate? If so, I would appreciate any suggestions you have for a good crate. @dherman and I have discussed maintaining Node bindings for some Rust crate to exemplify Neon best practices. Ideally, it would:
|
Yes → may_minihttp crate
Sure, I will do some checks and review. Please, can you start with a PR for the example of may_minihttp? |
@kjvalencik maybe it's better to add How can the /src/lib.rs of Draft of use neon::prelude::*;
use may_minihttp::{BodyReader, HttpServer, HttpService, HttpServiceFactorye, Request, Response};
// TODO re-export of BodyReader, HttpServer, HttpService, HttpServiceFactorye, Request, Response |
I created #100 |
@dherman please can you help? |
@rtritto, we are considering writing a Neon wrapper for the tantivy crate, although it's not at the top of our backlog at the moment. I don't think an HTTP server library (e.g., may_minihttp) is a good choice for an example. HTTP libraries have large API surface areas. Requests, responses, headers, errors, streaming, etc. and this is likely more than we would be able to have time to commit. Additionally, an HTTP server that needs to go over FFI is likely to perform significantly worse than the built-in Node.js server. The built in server is very fast and won't have the high overhead of Node-API calls. Native modules work best when large amounts of work can be performed at a time so that the overhead is amortized. |
So, to get best performances with an HTTP server the Node.js env, it's better to use uWebSockets.js (web server written in C++, benchs) instead of create a new one with Neon (use a web server written in Rust). Right? Anyway, with Neon, what's the best way to re-export |
A C++ web server won't perform any better than Neon/Rust. Both are bound by the same inefficiencies crossing the FFI boundary. To get an idea of how you might wrap some of these items, take a look at the gzip example. https://github.com/neon-bindings/examples/tree/main/examples/gzip-stream However, the more typical example would be going the other direction. A Node/JS HTTP server that calls into Neon. |
Add an example of the porting of a library.
E.g.: may_minihttp
Steps (draft):
The text was updated successfully, but these errors were encountered: