How do I make a remote call without defining a protobuf?

use NodeJS to implement the gateway layer, receive the HTTP request from the front end, and then forward it to the private network for RPC call. However, both the official documentation of gRPC and the Client implementation of the example need to refer to the protobuf file, for example: grpc.load ("/ xxxx.protobuf")

but every time you create a micro service, you need to submit a protobuf definition file at the gateway layer, which feels a bit inflexible, especially when it comes to updates and version management. I don"t know how big companies manage protobuf files. But I think that as a dynamic language, JS itself does not need to rely on protobuf to determine the data type. When interfacing with static languages such as golang, we can ignore the Stream calls of RPC and restrict the use of basic data types, such as string,int64,bool, when writing protobuf, to ensure that the data of JS can always be accurately converted to the types available in the static language.

so, how do I make a remote call without defining a protobuf? Or is there a better way to organize and manage protobuf?

< hr >

yesterday, by flipping through the document and source code, I wrote the following code, but it will report an error RPC method not implemented

.
import grpc from "grpc;

const client = new grpc.Client("127.0.0.1:3005", grpc.credentials.createInsecure())

client.makeUnaryRequest("GetService",
    function serialize(arg) {
        return new Buffer(JSON.stringify(arg));
    },
    function deserialize(argBuf) {
        // 
        console.log(typeof argBuf);
        return argBuf
    }, {
        name: "test"
    },
    null,
    null,
    function () {
        // 
        console.log(arguments);
    }
)

protobuf definition (partially omitted)

service Finder {
    rpc GetService (GetServiceRequest) returns (GetServiceReply) {}
}

message GetServiceRequest {
    string name = 1;
}

message GetServiceReply {
    string address = 1;
    string port = 2;
}
Does the author of

have an answer later? Want to realize

Menu