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

use gRPC client like ngx.fetch without subrequest #671

Open
ivanitskiy opened this issue Sep 15, 2023 · 3 comments
Open

use gRPC client like ngx.fetch without subrequest #671

ivanitskiy opened this issue Sep 15, 2023 · 3 comments

Comments

@ivanitskiy
Copy link

It would be beneficial to create a gRPC client in NJS similar ngx.fetch in the context of using it js_content or js_periodic to communicate with the external world.
A reference to LUA experimental capabilities: https://github.com/api7/grpc-client-nginx-module/blob/main/README.md

Here is an example of a node code using a gRPC client:
https://github.com/grpc/grpc-node/blob/%40grpc/grpc-js%401.9.0/examples/helloworld/dynamic_codegen/greeter_client.js

@drsm
Copy link
Contributor

drsm commented Sep 15, 2023

@ivanitskiy

    local gcli = require("resty.grpc")
    assert(gcli.load("t/testdata/rpc.proto"))

It looks like it will parse a proto file on every request.
I think, better to use something like pbjs

@ivanitskiy
Copy link
Author

@ivanitskiy

    local gcli = require("resty.grpc")
    assert(gcli.load("t/testdata/rpc.proto"))

It looks like it will parse a proto file on every request. I think, better to use something like pbjs

i'm not suggesting the exact thing, this is just a reference to the JS tutorial guide from gRPC project

@ivanitskiy ivanitskiy changed the title use gRPC client like ngs.fetch without subrequest use gRPC client like ngx.fetch without subrequest Sep 19, 2023
@rikatz
Copy link

rikatz commented Sep 21, 2023

I've been trying to do some experiences with pbjs and njs as well, but IMHO the way to get it working is too complex (a lot of steps prone to errors, browserfy the js, etc).

Also I wasn't able (my fault 99% sure) to make something useful like a simple grpc client, generating the frame and calling via subrequest a gRPC upstream so having something simpler on njs would be amazing.

I think generating the full js with pbjs is fine, but having something that we can do as simple as possible gRPC calls (or even generating njs compatible js, preloading it and calling the upstream) amazing!

Thanks for the hard work on it, njs is amazing

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

No branches or pull requests

3 participants