Web 快速使用 gRPC

更新时间: 2019-07-05 12:52

This guide gets you started with gRPC-Web with a simple working example.

Prerequisites

  • docker and docker-compose

This demo requires Docker Compose file version 3. Please refer to Docker website on how to install Docker.

Run an Echo example from the browser!

$ git clone https://github.com/grpc/grpc-web
$ cd grpc-web
$ docker-compose pull
$ docker-compose up -d node-server envoy commonjs-client

Open a browser tab, and go to:

http://localhost:8081/echotest.html

To shutdown, run docker-compose down.

What is Happening?

In this demo, there are three key components:

  1. node-server: This is a standard gRPC Server, implemented in Node. This server listens at port :9090 and implements the service’s business logic.
  2. envoy: This is the Envoy proxy. It listens at :8080 and forwards the browser’s gRPC-Web requests to port :9090. This is done via a config file envoy.yaml.
  3. commonjs-client: This component generates the client stub class using the protoc-gen-grpc-web protoc plugin, compiles all the JS dependencies using webpack, and hosts the static content echotest.html anddist/main.js using a simple web server at port :8081. Once the user interacts with the webpage, it sends a gRPC-Web request to the Envoy proxy endpoint at :8080.

What’s next

算法霸权

算法霸权

[美] 凯西·奥尼尔 / 马青玲 / 中信出版集团 / 2018-9-1 / 69.00元

数据科学家凯西•奥尼尔认为,我们应该警惕不断渗透和深入我们生活的数学模型——它们的存在,很有可能威胁到我们的社会结构。 我们生活在一个依赖“算法”的时代,它对我们生活的影响越来越大,我们去哪里上学,我是不是应该贷款买车,我们应该花多少钱来买健康保险,这些都不是由人来决定的,而是由大数据模型来决定的。从理论上来说,这一模型应该让社会更加公平,每一个人的衡量标准都是一样的,偏见是不存在的。 ......一起来看看 《算法霸权》 这本书的介绍吧!

JS 压缩/解压工具

JS 压缩/解压工具

在线压缩/解压 JS 代码

正则表达式在线测试

正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具

HEX HSV 转换工具

HEX HSV 互换工具