-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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 support for gRPC #3326
Comments
Sure, what do you mean? |
There is no gRPC module yet. |
would this be the way to go? https://github.com/stepancheg/grpc-rust |
Hello @tuddman , I understand that Deno is written over Rust but I think the question is about how I use gRPC in Deno, how do I write a gRPC client or server code in Deno? It's possible? Is there a library ready to use? If not, how to use the link you sent to provide a Javascript / Typescript api at the user level? |
Looking forward to the possibility of using gRPC with Deno. |
I believe that due to the popularity of gRPC it would be great to see support in the Deno standard library, like any other form of IO |
I would like to help with this integration, but I'm wondering if the best option is integration with grpc-rust or writing a typescript library? What about porting something like https://github.com/grpc/grpc-web/tree/master/packages/grpc-web as a typescript lib? |
IMO, this is something that should start external to Deno/ |
It should be noted the current advised approach of using gRPC in Node.js is to use the pure JavaScript module which uses Node.js's built-in modules (http2) instead of a native module built in c++. The module is built in TypeScript and perhaps can be used for inspiration for something in Deno, assuming http2 support is provided by Deno at some point. cc @murgatroid99 |
Hi. I'm the author of the existing gRPC libraries for Node.js. I think that porting I would not suggest porting grpc-web. That library implements a different protocol to account for the restrictions of browser APIs. It needs a proxy to talk to regular gRPC servers. |
I aggre about grpc-web maybe this should be another Deno module |
@murgatroid99 I have a doubt, how is gRPC-node generating code from Proto right now? |
There are two major methods: one is to use the The alternative is to use the I want to note that neither of these is strictly necessary in general to use |
Ok, let me understand a little bit. So first we need to implement something like |
That looks about right. One thing I want to note is that there is a kind of generic interchange format for defining a collection of services that Ideally I think gRPC for Deno should have the same API and functionality as the existing |
@murgatroid99 there is an article or a document explaining how grpc-node (or other C-grpc-based libraries) uses the core-grpc implementation? |
Another thing @murgatroid99, What do you think about building a |
I'm not aware of such a public document about using the gRPC core library. We did most of that work before we started doing our design work publicly. The simple answer, though, is that we defined a public API for JavaScript users (in this case), and then an intermediate API, that the implementation of the public API could consume and that we could reasonably implement in C++ using the core API. That intermediate API is considered non-public and not guaranteed to be stable. If you look at the The Node library in particular is unusual in that the gRPC core library has a libuv implementation of the low-level network interaction that was created specifically for the Node library, which can be enabled using a compiler flag. So the Node gRPC library enables that to simplify its interaction with the event loop. I think it's important to mention that the native addon was a maintainability nightmare, to the point that we decided to reimplement the library purely in TypeScript as Regarding implementing this on top of tonic, I think the important question is how close the desired JavaScript API is to the tonic API, semantically. In addition, how much extra work will it be to maintain the Deno equivalent of a native addon using a Rust library? And how does the total implementation work there compare with modifying |
I have taken a look at your pure TS implementation of grpc, and you are using only a single node dependency, so a deno library could be hard based on that implementation right? Based on what you said about the core library could be a nightmare in the long term, even with a Rust implementation. |
I like the typescript based approach. Maybe we need to implement http/2
first, then it is mostly straightforward.
…On Sat, Aug 15, 2020 at 11:36 AM yurianxdev ***@***.***> wrote:
I have taken a look at your pure TS implementation of grpc, and you are
using only a single node dependency, so a deno library couldn't be hard
based on that implementation? Based on what you said about the core library
could be a nightmare in the long term, even with a Rust implementation.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3326 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFW4HFVFN36VLGRWRRF75DSA3ITXANCNFSM4JMRSKMA>
.
|
There is no progress on HTTP2 (#3995) so if we want to follow the pure TS approach we need to implement it. That will kill two birds with one shot, I like it. |
HTTP2 will eventually land. Again, this needs to start as something seperate from |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
any news on this ? |
Hi! I'm a maintainer from mali (GRPC microservice framework) and wanted to stay in the loop. We're currently investigating supporting Deno in Mali. If you're interested in this support, please send us a message from malijs/mali#241 |
Seems Deno 1.9, released today, implements HTTP 2.0 🎉 |
Support for gRPC in the Deno CLI will be an extremely nice feature, thank you for choosing to do so! |
FYI, I posted a runtime API proposal for gRPC support in the discussions. #17308 |
Add `ref` and `unref` to return value from `Deno.serve`. Unblocks #3326.
Hey, what is the status here? Can we expect support for gRPC ? |
Hi @donoso-eth. We are actively working to support https://www.npmjs.com/package/@grpc/grpc-js in Deno. Right now, the following official client examples work if you use es modules (here is a branch with updated examples)
The next steps are to get the error_handling example working and popular packages that rely on gRPC. Note that server examples don't work yet and we will focus on them once we have the clients working. |
It's very cool to know grpc-js will be available on Deno soon, I would also like to know what the performance it would be. Since Deno already has a very performant built-in HTTP server, I would expect Deno will eventually have a gRPC implementation at the same performance level. I also wonder if it's possible to achieve that performance via pure JavaScript, or if some parts must be written in Rust. |
So the blog post make it look like everything is working. Is that the case? Anyone how has a repro readily available to try this out? https://deno.com/blog/v1.44#grpc-connections-now-supported Related |
@birkskyum we have support for all of the official gRPC client side examples and we also tested google packages like vision that rely on gRPC client APIs and they are working. We don't support the server side yet. Edit: Re: example The example from the blog post should work with GCP Application Default Credentials setup and an image on the local disk to test. If you do find any issue, please report and we will fix them. |
@rnbguy @satyarohith I am using grpc_basic, but it's getting an error, and the author of that library is no longer providing support. For the grpc_basic example in the server, it needs Deno to listen on a port, and the grpc_server will handle that port (Deno.TCPConn), as shown in the image below: Now, as you say, Deno v1.44 now support grpc/grpcjs. so I want to implement grpc/grpc-js, but I have a small issue. The library needs bindAsync directly on the port, and there's no longer a need for using Deno.listen. However, I want to know if it's possible to use Deno.listen instead? |
hey @xiaojiudev, I am not really part of the Deno team. But AFAIK, the current Deno |
I am trying to get a grpc client working in deno. I used protobufjs-cli to generate a JS and d.ts file.
I tried changing the file to .mjs as well. Also inside the generated JS file, getting this where it says
Generated JS file looks something like this: /*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
(function(global, factory) { /* global define, require, module */
/* AMD */ if (typeof define === 'function' && define.amd)
define(["protobufjs/minimal"], factory);
/* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
module.exports = factory(require("protobufjs/minimal"));
})(this, function($protobuf) {
"use strict";
// Common aliases
const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
export const lnrpc = $root.lnrpc = (() => {
/**
* Namespace lnrpc.
* @exports lnrpc
* @namespace
*/
const lnrpc = {};
lnrpc.Lightning = (function() {
/**
* Constructs a new Lightning service.
* @memberof lnrpc
* @classdesc Represents a Lightning
* @extends $protobuf.rpc.Service
* @constructor
* @param {$protobuf.RPCImpl} rpcImpl RPC implementation
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
*/
function Lightning(rpcImpl, requestDelimited, responseDelimited) {
$protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited);
}
```
|
I'm running Deno 1.44.4 and have a client working. Unfortunately everything seems to stop working after 1 minute 40 seconds. I've run exactly the same code using NodeJS and there is no problem. My code simply opens a stream and listens for events. Unfortunately I don't have any errors I can report from the output. |
I just submitted a new issue - #26436 that seems related to Deno's lack of support for server-side gRPC. |
Closing this thread as the original issue is about gRPC client applications which are now supported. Please open new issues for bugs related to clients. And support for server side is being tracked at #23714 |
Is it possible to write a gRPC client application in Deno?
The text was updated successfully, but these errors were encountered: