julien-pal / node-red-contrib-grpc

Node RED wrapper for gRPC
9 stars 11 forks source link

Do grpc-server nodes support import in proto files? #19

Open jeff-bonevich opened 3 years ago

jeff-bonevich commented 3 years ago

I do not see support for imports of external proto files into the definition supplied to a grpc-server? Is this a feature on the roadmap? or am I (as usual) just missing how to do this? Thanks!

namgk commented 3 years ago

Is there a problem with copy/pasting the content? Sorry I was a bit busy, will working on the PR as soon as I can.

jeff-bonevich commented 3 years ago

Well, it might honestly be my inexperience with gRPC. I need to import a separate proto file that has a different package namespace for messages. So if I have the following:

syntax = "proto3";
import "SiLAFramework.proto";

package bonez.dht11;

// Feature: DHT11 SiLA2 Provider
//   SiLA2 drivers for the DHT11 Humiture Sensor
service DHT11Provider {
    rpc GetTemperature(bonez.dht11.GetTemperature_Parameters) returns (bonez.dht11.GetTemperature_Responses) {}
    rpc GetHumidity(bonez.dht11.GetHumidity_Parameters) returns (bonez.dht11.GetHumidity_Responses) {}
}

// ------ Command Parameter and Response definitions -------
message GetTemperature_Parameters {
}

message GetTemperature_Responses {
    sila2.org.silastandard.Real Temperature = 1;
}

message GetHumidity_Parameters {
}

message GetHumidity_Responses {
    sila2.org.silastandard.Real Humidity = 1;
}

and the references to sila2.org.silastandard.Real come from the import:

syntax = "proto3";

package sila2.org.silastandard;

option java_outer_classname = "SiLAFramework";

// -------- SiLA Basic Types --------
[snipped]

message Real {
    double value = 1;
}

and I am unsure then how I can just paste in the 'Real' message definition as 'message sila2.org.silastandard.Real..' gives me errors:

"createGRPCServer - Error: illegal type name 'sila2.org.silastandard.Real' (/var/folders/vr/9bgzlkzs4z7_zxmv64n70d5xg15dzy/T/foobar-jcNOFO/proto.txt, line 29)"
namgk commented 3 years ago

Oh no this isn't supported. The only packages you can import is the standard ones from google: com.google...

A quick workaround I suppose, is to merge your proto files into one file and then copy the content over to the node.

On Wed., Apr. 21, 2021, 7:00 p.m. Jeff Bonevich, @.***> wrote:

Well, it might honestly be my inexperience with gRPC. I need to import a separate proto file that has a different package namespace for messages. So if I have the following:

syntax = "proto3"; import "SiLAFramework.proto";

package bonez.dht11;

// Feature: DHT11 SiLA2 Provider // SiLA2 drivers for the DHT11 Humiture Sensor service DHT11Provider { rpc GetTemperature(bonez.dht11.GetTemperature_Parameters) returns (bonez.dht11.GetTemperature_Responses) {} rpc GetHumidity(bonez.dht11.GetHumidity_Parameters) returns (bonez.dht11.GetHumidity_Responses) {} }

// ------ Command Parameter and Response definitions ------- message GetTemperature_Parameters { }

message GetTemperature_Responses { sila2.org.silastandard.Real Temperature = 1; }

message GetHumidity_Parameters { }

message GetHumidity_Responses { sila2.org.silastandard.Real Humidity = 1; }

and the references to sila2.org.silastandard.Real come from the import:

syntax = "proto3";

package sila2.org.silastandard;

option java_outer_classname = "SiLAFramework";

// -------- SiLA Basic Types -------- [snipped]

message Real { double value = 1; }

and I am unsure then how I can just paste in the 'Real' message definition as 'message sila2.org.silastandard.Real..' gives me errors:

"createGRPCServer - Error: illegal type name 'sila2.org.silastandard.Real' (/var/folders/vr/9bgzlkzs4z7_zxmv64n70d5xg15dzy/T/foobar-jcNOFO/proto.txt, line 29)"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/julien-pal/node-red-contrib-grpc/issues/19#issuecomment-824481697, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHU7IAJXJROBJNPAGDRXCTTJ57MPANCNFSM43LL3SGQ .