bkono / microdc-example

Example of docker-compose, consul in docker-compose, go-micro, and more.
0 stars 4 forks source link

extending to support gomobile #1

Open ghost opened 6 years ago

ghost commented 6 years ago

i saw https://github.com/bkono/msgme

Nice stuff.

i have some ideas and wanted to ask you before i do any PR's.

  1. I saw you playing with Fuse. Well now there is Flutter. You can expose java and Objective C 7 Swift as plugins and under those you can have golang that was compiled with gomobile :) Its a kind of huge i feel.

See: https://github.com/flutter/flutter/search?q=gomobile&type=Issues

There are 2 ways to hook up golag to Flutter

a. Direct over GRPC network.

https://github.com/grpc/grpc-dart

https://medium.com/dartlang/announcing-official-grpc-support-for-dart-6c9b50357af6

b. By making a flutter plugin and having gomobile code inside the plugin.

https://flutter.io/platform-channels/

SO you can basically expose golang code on the mobile / or desktop ) as a Flutter plugin using Method Channels. BTW they will open up Platform Channles soon so you can write mobile background services too ! SO, my question... Have you tried exposing the binary protobufs on the gomobile binding layer, in order to avoid all the weird type conversion stuff between languages ? Then passing the protobufs through the Java and Swift / Objective C layer to exposing them directly to the Flutter GUi layer ? Its just an idea to make it all much easier because Dart has proper Protobuf and GRPC support.


Why do this ? Mainly because you get code sharing between the server and the client. Databases, logic, you name it :)

bkono commented 6 years ago

Thanks for the ping. So far I haven't spent much time looking at flutter, mostly because I didn't like my initial UI experience compared to fuse. What you're describing though is exactly how I treat fuse & go: centralize any shared logic, networking magic, etc in go with a thin layer for gomobile, and then another layer to bubble it up from uno to javascript. I'd love to reduce the layers a bit. If it ends up being cleaner to take that approach in flutter, it might be worth a second look. Desktop support is a win as well.

Re: the q on exposing the protos ... I don't expose them directly, because I actually want the extra goodies that come from bringing go-micro into the mix. With the app mentioned in msgme's README, its specifically the registry, mdns support, circuit breaker logic, and a few other things that are all set to go with go-micro and some client wrappers. Going straight to the protos would leave me still needing to implement the other functionality at the client level, mdns discovery being the primary pita when I did it in straight android previously.

I'm game for seeing what it would look like to bring flutter & gomobile into the mix. Not sure if this repo is the right landing place for it, or if it should get something dedicated, but if you've got something in mind I'd love to see it. Feel free to PR it for discussion, or just fork and drop a link back in the issue.

ghost commented 6 years ago

i think i get it.

so on the client you have the mdns stuff working now ?

bkono commented 6 years ago

Yep. In the app msgme is based on, my android tablets automatically discover a few micro based gRPC services on launch. msgme is configured to do essentially the same thing, https://github.com/bkono/msgme/blob/master/sdk/client.go#L28 - mdns is set in the "sdk" package when initializing a new client. I'd previously done something similar in pure android by doing direct gRPC comms, and implementing my own zeroconf discovery + metadata parsing to fake a registry ... it was miserable. gomobile + fuse made it trivial, with very easy UI paradigms and fully shared code.

ghost commented 6 years ago

your really loving fuse it seems.

whats the pricing deal ? Its like React native ?

G

On Thu, 19 Apr 2018 at 17:09 Bryan Konowitz notifications@github.com wrote:

Yep. In the app msgme is based on, my android tablets automatically discover a few micro based gRPC services on launch. msgme is configured to do essentially the same thing, https://github.com/bkono/msgme/blob/master/sdk/client.go#L28 - mdns is set in the "sdk" package when initializing a new client. I'd previously done something similar in pure android by doing direct gRPC comms, and implementing my own zeroconf discovery + metadata parsing to fake a registry ... it was miserable. gomobile + fuse made it trivial, with very easy UI paradigms and fully shared code.

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bkono/microdc-example/issues/1#issuecomment-382772518, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuCwsV_sBxgR7cXWmWmQD0P6ZwCX9_pks5tqKi6gaJpZM4TZtFS .

bkono commented 6 years ago

Haha. Wouldn't necessarily say loving, more like ... used in anger and came out relatively unscathed. :) Def open to seeing if flutter is a good alternative though.

Fuse pricing at the time (think it still is) is free, with plans to get access to extra tooling (a designer-y studio, xcode integrations, etc) and premium prebuilt components. Personally haven't had a need for those things in my usage.

ghost commented 6 years ago

I will def stick with Flutter. Fuse does not really have a chance IMHO to keep up. ALso the plugins are amazing to use

i have gotten flutter and golang talking over GRPC and Graphql in 3 days. its very productive. Dart GRPC, protofus is decent quality. github.com/grpc/grpc-dart

Dart GraphQL is lacking but enough to do real work. github.com/spacedragon/graphql-fetch

On Fri, 20 Apr 2018 at 23:23 Bryan Konowitz notifications@github.com wrote:

Haha. Wouldn't necessarily say loving, more like ... used in anger and came out relatively unscathed. :) Def open to seeing if flutter is a good alternative though.

Fuse pricing at the time (think it still is) is free, with plans to get access to extra tooling (a designer-y studio, xcode integrations, etc) and premium prebuilt components. Personally haven't had a need for those things in my usage.

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bkono/microdc-example/issues/1#issuecomment-383226438, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuCwlHtAyhliTKeF3ET-qA9oFHSlbUvks5tqlGzgaJpZM4TZtFS .

bkono commented 6 years ago

@gedw99 So... I decided to take a good look at flutter following i/o πŸ˜„. Its moving along really well, though still immature on some key things, like inline webview with injected js (vital for a lot projects I've been on) or a native gmaps view. Did some interactivity experiments with forward/reverse animations, and while I think the api is overly complicated vs a good declarative markup, its still super powerful.

I'm sure that the missing stuff will come in time, so I'm trying to do a little project in it, maybe add a flutter client app to msgme to get a feel for it before building something significant. Couple q's for you: have you done anything with complex state that warranted redux/streams? I like the streams approach I saw in the Building Reactive Apps talk from i/o, but it does immediately raise the dependency injection question. Any experience with that, or libraries you'd recommend? Other q, since you mentioned grpc... have you experimented at all with twirp? I've found the codebase less hacky, and pretty nice for use in lambda-based apis backing mobile apps.

ghost commented 6 years ago
  1. Re Redux

    • use Rx Dart. its pretty easy compared to the heaviness of Reflux. Build_reflux is the best one for flutter as it included code gen
    • I like to use GPRC for all data model, and so rx dart is easier to use.
  2. Twirp

    • i saw it and was like "whats the big deal. Really its like no one has seen grpc-web from improbable. I just did not at all see value added by twirp. grpc has interceptors, Prometheus the whole shooting match and now grpc over websockets with web browser.
  3. Flutter

    • there is a google maps plugin on tits way that is supported by google.
    • i need webview with injected JS too !!!. I think that are a few there. If you need to inject JS cant you do it over the eval maybe ? Not sure though. I REALLY need the same actually.

G

On Sat, 12 May 2018 at 19:26 Bryan Konowitz notifications@github.com wrote:

@gedw99 https://github.com/gedw99 So... I decided to take a good look at flutter following i/o πŸ˜„. Its moving along really well, though still immature on some key things, like inline webview with injected js (vital for a lot projects I've been on) or a native gmaps view. Did some interactivity experiments with forward/reverse animations, and while I think the api is overly complicated vs a good declarative markup, its still super powerful.

I'm sure that the missing stuff will come in time, so I'm trying to do a little project in it, maybe add a flutter client app to msgme to get a feel for it before building something significant. Couple q's for you: have you done anything with complex state that warranted redux/streams? I like the streams approach I saw in the Building Reactive Apps talk https://events.google.com/io/schedule/?section=may-8&sid=dab2bf45-6e44-4605-a997-9d446f95ef38&myio=true from i/o, but it does immediately raise the dependency injection question. Any experience with that, or libraries you'd recommend? Other q, since you mentioned grpc... have you experimented at all with twirp? I've found the codebase less hacky, and pretty nice for use in lambda-based apis backing mobile apps.

β€” You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/bkono/microdc-example/issues/1#issuecomment-388570355, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuCwpRoG2uVImm1f7FXRb5JKV4Yu9Ljks5txxs8gaJpZM4TZtFS .

bkono commented 6 years ago

Thanks for info!

  1. Re Redux
    • use Rx Dart. its pretty easy compared to the heaviness of Reflux.

Interesting. Maybe because I've been doing "observables" since the early backbone/knockout days, and stabbed at Rx* in several languages, I've found redux (or at least vuex) patterns a breath of fresh air and Rx to create heavy architectures. Will def give this a look though, especially if its a good fit for the dart ecosystem.

  1. Twirp
    • i saw it and was like "whats the big deal. Really its like no one has seen grpc-web from improbable.

Ha, I had the exact same "who cares" gut reaction when I first looked at it. Having used it a bit, theres some use cases where its convenient, though unary streaming is really needed. Specifically around serverless where grpcweb falls down in perf (ms == $$), client gen without free standing proxies, and various quirks of http/2 like trailer usage. That, and grpc has notoriously low quality code, which has bit me a number of times now. Still my go to for stateful, long lived services just because of the engineering effort going into it and the option of persistent connections, but those scenarios are getting less and less common.

Looks like I've got some homework to do in dart-land. :)

ghost commented 6 years ago

In regards to GRPC and unary streaming ... I should point out that i am NOT aiming to Support Web browsers for serious sutff. I have to use a webview on desktops ( because life is too short and it works), but the GRPC layer is all running outside the web browser in a desktop service. The desktop service has a DB, etc. SO when a stream of data comes in from wherever i can just notify the Webview "hey new namespace of data here for you". Basically a pub sub running locally between the Service and the webview.

So i still use GRPC-web for pure world facing server to browser interaction and i use gopherjs heavily for it.

I should try to share some of my stack with THIS repo if you interested in Flutter. Flutter Desktop btw will happen. The code is sitting there in googles repo in PR#s etc. I just think they are not ready to have to support the Microsoft moving target crap shoot just yet. Flutter mobile is running at about 3500 github issues for example. Also it might be strategic. Why help Desktops when you have ChromeOS, but i dont think its that blatant. Could be wrong..

bkono commented 6 years ago

Sounds like an interesting architecture. If you have something to share, I'd love to see it.

On Sat, May 12, 2018 at 9:45 PM, gedw99 notifications@github.com wrote: In regards to GRPC and unary streaming ... I should point out that i am NOT aiming to Support Web browsers for serious sutff. I have to use a webview on desktops ( because life is too short and it works), but the GRPC layer is all running outside the web browser in a desktop service. The desktop service has a DB, etc. SO when a stream of data comes in from wherever i can just notify the Webview "hey new namespace of data here for you". Basically a pub sub running locally between the Service and the webview.

So i still use GRPC-web for pure world facing server to browser interaction and i use gopherjs heavily for it.

I should try to share some of my stack with THIS repo if you interested in Flutter.

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub [https://github.com/bkono/microdc-example/issues/1#issuecomment-388600720] , or mute the thread [https://github.com/notifications/unsubscribe-auth/AAK8b3il3oyTsRpRujmFhlQ6L9Xm_ISnks5tx7pRgaJpZM4TZtFS] .