google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
23.1k stars 3.22k forks source link

Question: Grpc-web support? #5260

Closed shaunc closed 3 years ago

shaunc commented 5 years ago

Are there any plans to support grpc-web, or knowledge of 3rd-party projects that do so?

We are designing a browser-based visualization tool, which we'd like to connect to Golang services which currently use flatbuffers (though they could be changed to use protobuf). In the browser we'd like to access the data directly in flatbuffers to minimize browser memory consumption.

aardappel commented 5 years ago

There are no plans, gRPC support for different languages/systems happens when someone implements it.. PRs welcome!

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity for 1 year. It will be automatically closed if no further activity occurs. To keep it open, simply post a new comment. Maintainers will re-open on new activity. Thank you for your contributions.

rektide commented 4 years ago

a new comment. edit: apologies i hope this is not overly rude. i wanted to keep this very interesting capability open for discussion.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

mustiikhalil commented 3 years ago

I've been actually thinking of implementing it for node JS.

mustiikhalil commented 3 years ago

@krojew I've been thinking of how do we add GRPC to FlatBuffers on nodeJS, and after a bit of experimentation I found out that we can do the following:

class Message {
  constructor(data) {
    this.data = data
  }

  getData() {
    if (this.data) {
      // we return a Buffer for the data that can be passed into Flatbuffers/grpc
      return new Buffer.from(this.data)
    }
    throw new Error('Data cant be empty');
  }
}

function serialize_Message(arg) {}
function deserialize_Message(buffer_arg) {}

var GreeterService = exports.GreeterService = {
  // routes for greeting
  sayHello: {
    path: '/helloworld.Greeter/SayHello',
    requestStream: false,
    responseStream: false,
    requestType: Message, // Uses only one class which would make the user responsible for managing their buffers
    responseType: Message,
    requestSerialize: serialize_Message,
    requestDeserialize: deserialize_Message,
    responseSerialize: serialize_Message,
    responseDeserialize: deserialize_Message,
  },
};

what do you think?

krojew commented 3 years ago

Unfortunately, I don't know grpc enough to have an opinion on this.

shaunc commented 3 years ago

When I was actively interested I asked around:

Seemed that stakeholders were open to it but no one wanted to go first. Personally I have too many other tasks to take the lead, but perhaps could help support when I find time or if it comes to bug-fixes.

mustiikhalil commented 3 years ago

@shaunc I mean I've tested it around and it works, I just want to know what's the best practice since I usually work with swift and not JS. FYI, I will start by adding support to this grpc-node

But when I am ready to PR, I'll definitely tag you so you can take a look

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

sahendrickson commented 1 year ago

Did anyone ever get this working or build some support for it? The generated grpc code only works in node.js, not the web.