bluehouse-technology / grpc Goto Github PK
View Code? Open in Web Editor NEWErlang library for GRPC
License: Apache License 2.0
Erlang library for GRPC
License: Apache License 2.0
@willemdj Hi,
I saw your thread on HTTP/2 features in cowboy. I have been working on an HTTP/2 server. It is clearly not as mature as cowboy but was developed HTTP/2 first so might be more useful for a GRPC foundation. The possible downside from your point of view is at the moment it is in Elixir. I haven't yet worked out how to use an Elixir lib in erlang but I would certainly like to set that up.
Quick summary of the issues you raised here ninenines/cowboy#1191
start the server example "grpc:start_server(hello, tcp, 10000, helloworld_server, [])." it should be "grpc:start_server(hello,tcp,10000,#{'ServiceName'=> helloworld_server},[])."
Dependencies are only listed in the makefile so will not be fetched when used as a dependency in a rebar3 project.
Happy to send a PR later today.
I'm working on some changes and wanted to run the changes by you before getting to far.
The issue I was dealing with was wanting to host multiple services handled by different modules from the same server port. Currently the grpc app only accepts 1 module name.
Here is the example converted to what I'm thinking:
> {ok, Server} = grpc:start_server(grpc, tcp, 10000, [#{service => route_guide,
defs_module => route_guide,
handler => route_guide_server_1}]).
This would also remove the need for the function decoder() -> route_guide.
binary_to_existing_atom(B) ->
list_to_existing_atom(binary_to_list(B)).
Is that conflict with ”erlang:binary_to_existing_atom/1“? ==> https://erlang.org/doc/man/erlang.html#binary_to_existing_atom-1
Is the library compatible for gprc web client? If not, any ideas?
I have 2 connections and in each connection bidirectional streams and when the client from the first connection sends something to sever I want to forward it to client from the second connection. How to access the other connection if I eg know both processes PIDs form ets table?
There are headers that shouldn't be hard coded, because of this is not possible to consume external gRPC APIs, for example Google Services (in my case Spanner).
These are some of them:
:scheme
- https://github.com/Bluehouse-Technology/grpc/blob/master/src/grpc_client_lib.erl#L156 - This one should be obtained from the connection scheme.:authority
- https://github.com/Bluehouse-Technology/grpc/blob/master/src/grpc_client_lib.erl#L158 - This one may be obtained from the Host.Don't know if make sense but other solution (which could be useful for some cases) might be allowing headers overriding the headers, using the metadata (merge both proplists instead of append them - https://github.com/Bluehouse-Technology/grpc/blob/master/src/grpc_client_lib.erl#155) – this was the workaround I did to make it work against Google, but not sure if it is the right way.
Stay tuned! Thanks!!
what is the current status of the lib? how far it is from prod?
I use proto file generate a java server, then use same file to generate erlang grpc module, but I can't fond a option to specific "package" instead erlang "module"?
%% This is a unary RPC
onConnect(Connection, Message, Options) ->
grpc_client:unary(Connection, Message,
'RequestHandler', onConnect,
decoder(), Options).
Such example, my java package is com.test.RequestHandler.java
, When I generate the entire package it not appear.
I need this:
onConnect(Connection, Message, Options) ->
grpc_client:unary(Connection, Message,
'com.test.RequestHandler', onConnect,
decoder(), Options).
It is my proto file(test.proto):
syntax = "proto3";
option java_package = "com.test";
option java_outer_classname = "Types";
package grpcserver;
//---------------------------
message AuthRequest{
string clientId = 1;
string username = 2;
string password = 3;
}
//....
How can I config package?
Following the tutorial I try to run my own service and get an error. What could I have done wrong?
{ok, Connection} = grpc_client:connect(tcp, "localhost", 10000).
{ok, Stream} = grpc_client:new_stream(Connection, 'Send', 'SendMessage', speak).
** exception error: no match of right hand side value {error,<<"failed to create stream">>}
speak.proto
syntax = "proto3";
option java_multiple_files = true;
package Send;
service Send {
rpc SendMessage(Message) returns (readReciept) {}
}
message Message {
string messageContent = 1;
}
message readReciept {
string reciept = 1;
}
speak_client.erl
-module(speak_client).
%% this file was generated by grpc
-export(['SendMessage'/3]).
-type 'Message'() ::
#{messageContent => string()}.
-type readReciept() ::
#{reciept => string()}.
-export_type(['Message'/0,
readReciept/0]).
-spec decoder() -> module().
%% The module (generated by gpb) used to encode and decode protobuf
%% messages.
decoder() -> speak.
%% RPCs for service 'Send'
-spec 'SendMessage'(
Connection::grpc_client:connection(),
Message::'Message'(),
Options::[grpc_client:stream_option() |
{timeout, timeout()}]) ->
grpc_client:unary_response(readReciept()).
%% This is a unary RPC
'SendMessage'(Connection, Message, Options) ->
grpc_client:unary(Connection, Message,
'Send', 'SendMessage',
decoder(), Options).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.