grpc-dart icon indicating copy to clipboard operation
grpc-dart copied to clipboard

Support creating client with Streams

Open empirefox opened this issue 7 years ago • 8 comments

It is easier to invoke golang code from flutter code. Due to less ios/android code and class-struct mapping, coding errors will be reduced.

empirefox avatar Sep 04 '18 06:09 empirefox

Not sure what you mean. Can you be more detailed ?

ghost avatar Sep 04 '18 06:09 ghost

When calling golang api from flutter, currently we must write the ios/android version api for every golang api. If it is possible to create grpc client using stream and sink(currently only accept ip:port), we can make dart-golang calls easier, because we only need to establish a virtual connection(stream and sink) to golang code through the platform channel. The android/ios code do not need to be changed when a golang api changes. I'm sorry for my poor English.

empirefox avatar Sep 04 '18 08:09 empirefox

now i understand what you mean. You want to run golang inside flutter ?

ghost avatar Sep 06 '18 08:09 ghost

Yes. And i want to make it more easier to maintain for me. I am not familiar with android/ios, so I want make the the platform code to be decoupled from the business.

empirefox avatar Sep 06 '18 09:09 empirefox

What you're asking for is not doable yet due to limitation in Flutter, not grpc-Dart. This is evident by the discussion in Flutter in the links below:

https://github.com/flutter/flutter/issues/2396

https://github.com/flutter/flutter/issues/7053

mohammed90 avatar Sep 06 '18 10:09 mohammed90

Yes, flutter call C/C++ directly is impossible. But using platform channel to only pass binary data is feasible.

empirefox avatar Sep 06 '18 10:09 empirefox

I created a flutter plugin, which can create a pair of (StreamSink<List>, Stream<List>). From flutter it can establish a http2 connection:

    // 9999 is not a system port.
    // golang: ln,err := forgo.Listen(9999)
    _conn = await Conn.dial(9999);
    _conn.done.then((_) {
      _conn.close();
    });
    _transport = ClientTransportConnection.viaStreams(_conn.receiveStream, _conn);

So i need a way to create grpc client from that _transport or _conn.

empirefox avatar Sep 23 '18 05:09 empirefox

https://github.com/flutter/flutter/issues/7053 has now been solved btw !!!

ghost avatar May 05 '19 23:05 ghost