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

网站搜索设计

网站搜索设计

[美] Shari Thurow、[美] Nick Musica / 向怡宁 / 人民邮电出版社 / 2011-4 / 35.00

本书是提高网站搜索可用性的红宝书,它将SEO 和Web 可用性两个不同领域的知识融会贯通,详细阐述了用户的各种搜索行为和行为背后的真实意图,以及网站如何迎合用户心理,以便提供令其满意的内容,进而实现网站所有者的商业目标。 本书不仅仅是SEO 专业人员和Web 可用性人员的参考必备,同时更可为网络文案、设计开发人员、营销专员以及网站所有者、管理者等其他Web 领域从业人员拓展视野、补强技能。一起来看看 《网站搜索设计》 这本书的介绍吧!

在线进制转换器

在线进制转换器

各进制数互转换器

UNIX 时间戳转换

UNIX 时间戳转换

UNIX 时间戳转换

RGB CMYK 转换工具

RGB CMYK 转换工具

RGB CMYK 互转工具