akoua / grpc_demo

gRPC implemented with Go server and Flutter client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gRPC Demo

Demonstration of the gRPC protocol with a Go server and a Flutter client.

Why gRPC?

gRPC is an alternative to HTTP-JSON which sends structured binary data over HTTP/2 instead of plaintext JSON, resulting in performance increases and more portable models. This is accomplished through the use of Protocol Buffers for model development.

gRPC

Running the Demo

Start Server

To start the server:

docker-compose up

This will launch the gRPC server as well as the Envoy proxy required to run the demo on Flutter Web (explained below).

Start Client

To start the client:

cd client && flutter run

Running on a Device

In order to run the Flutter demo on a device (instead of a simulator), you must use ngrok to tunnel the TCP traffic (requires a free ngrok account).

ngrok tcp 50051

ngrok output

After running this command, you'll need to copy the Forwarding address to client/lib/core/config/config.dart (lines 13 and 24). For Flutter Web, the port is always 8080 because its traffic is routed through the Envoy proxy.

Running on the Web

In order to use gRPC on the web, the grpc-web library is used. Currently, only unary and server-side streaming are supported. Moreover, an intermediate proxy is required to convert HTTP/2 requests and responses to HTTP/1 for the browser. For more information, see this blog post.

grpc-web

About

gRPC implemented with Go server and Flutter client


Languages

Language:Dart 85.2%Language:Go 5.9%Language:Ruby 5.2%Language:HTML 1.8%Language:Swift 0.6%Language:Dockerfile 0.6%Language:Shell 0.4%Language:Kotlin 0.2%Language:Objective-C 0.1%