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

大学程序设计课程与竞赛训练教材

大学程序设计课程与竞赛训练教材

吴永辉、王建德 / 机械工业出版社 / 2013-6 / 69.00

本书每章为一个主题,实验内容安排紧扣大学算法和数学的教学,用程序设计竞赛中的算法和数学试题作为实验试题,将算法和数学的教学与程序设计竞赛的解题训练结合在一起;在思维方式和解题策略的训练方面,以问题驱动和启发式引导为主要方式,培养读者通过编程解决问题的能力。 本书特点: 书中给出的234道试题全部精选自ACM国际大学生程序设计竞赛的世界总决赛以及各大洲赛区现场赛和网络预赛、大学程序设计竞......一起来看看 《大学程序设计课程与竞赛训练教材》 这本书的介绍吧!

CSS 压缩/解压工具

CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Base64 编码/解码

Base64 编码/解码

Base64 编码/解码