A JavaScript implementation of gRPC for browser clients. For more information, including a quick start, see the gRPC-web documentation. RPC-web clients connect to gRPC services via a special proxy; by default, gRPC-web uses Envoy. In the future, we expect gRPC-web to be supported in language-specific web frameworks for languages such as Python, Java, and Node. For details, see the roadmap. Client-side and Bi-directional streaming is not currently supported (see streaming roadmap). Eager to get started? Try the Hello World example. You can also try to run a more advanced Echo app from the browser with a streaming example. Open a browser tab, and visit http://localhost:8081/echotest.html. To shutdown: docker-compose down. If you don't already have protoc installed, download it first from here and install it on your PATH. If you don't have protoc-gen-js installed, download it from protocolbuffers/protobuf-javascript and install it on your PATH. Make sure all executables are discoverable from your PATH. After the command runs successfully, you should now see two new files generated in the current directory.
You can then use Browserify, Webpack, Closure Compiler, etc. to resolve imports at compile time. The default generated code has Closure goog.require() import style. The CommonJS style require() is also supported. In addition to above, a .d.ts typings file will also be generated for the protobuf messages and service stub. The service stub will be generated in TypeScript. See TypeScript Support below for information on how to generate TypeScript files. For more information about the gRPC-web wire format, see the specification. The default generated code sends the payload in the grpc-web-text format. Both unary and server streaming calls are supported. A binary protobuf format is also supported. Payload are in the binary protobuf format. Only unary calls are supported. Let's take a look at how gRPC-web works with a simple example. You can find out how to build, run and explore the example yourself in Build and Run the Echo Example.
The first step when creating any gRPC service is to define it. Like all gRPC services, gRPC-web uses protocol buffers to define its RPC service methods and their message request and response types. Next you need to have a gRPC server that implements the service interface and a gateway proxy that allows the client to connect to the server. Our example builds a simple Node gRPC backend server and the Envoy proxy. For the Echo service: see the service implementations. For the Envoy proxy: see the config yaml file. Once the server and gateway are up and running, you can start making gRPC calls from the browser! For an in-depth tutorial, see this page. You can set a deadline for your RPC by setting a deadline header. The value should be a Unix timestamp, in milliseconds. The grpc-web module can now be imported as a TypeScript module. This is currently an experimental feature. For the full TypeScript example, see ts-example/client.ts with the instructions to run. UnaryInterceptor (doc, example) - Intercept Unary RPCs; can only be used with Promise clients. StreamInterceptor (doc, example) - More versatile; can be used with regular clients.
Globalization is a hot buzzword in the media right now, and for good reason. Many corporations are have operations worldwide. A large company might have offices on multiple continents. And some large companies are making unprecedented alliances with competitors. While face-to-face interactions still play an important role in conducting business, it's just not possible to limit all collaborative projects to personal meetings. That's why many companies are looking into online collaboration. Online collaboration uses the Internet as a common meeting and work space. Instead of sitting in a physical conference room, employees access virtual work environments. That work space might be a shared database in which employees can store and access data in a collaborative way, or it might be as complex as a full-fledged virtual environment. They save their work in a shared database, and everyone works from the same files and data. Not only are there technical challenges that companies must address when investing in online collaboration, but there are also social concerns.
|