Skip to content

ekkinox/grpc-demo

Repository files navigation

🚀 gRPC: SOA booster

Introduction session to gRPC as SOA booster using Golang.

Table of contents

Installation

First install required dependencies:

Then start the stack:

docker-compose up -d

Stubs generation

The protoc stubs are generated using Buf, following rules in buf.gen.yaml file.

To launch a new generation:

buf generate

Then check the proto folder where you'll find:

  • go: golang generated stubs for gRPC server and gRPC gateway
  • js: javascript generated stubs for web clients
  • php: PHP generated stubs for PHP application (as gRPC client)

Available services

Name Host Description
gRPC server localhost:50051 The gRPC server (go)
gRPC gateway localhost:8888 The gRPC gateway (go)
gRPC envoy proxy localhost:9999 The gRPC envoy proxy (envoy)

gRPC server

This application is a simple server side go implementation of the text_tools.proto Protobuf definition.

The code is located in server folder.

You can access it on localhost:50051, and use the provided client/main.go script to interact with it:

cd client && go run .

gRPC gateway

This application is a REST <-> gRPC reverse proxy using autogenerated protoc stubs.

The code is located in gateway folder.

You can access it on localhost:8888 to interact with it on following endpoint:

Endpoint Description
[POST] /v1/transform To call with REST the TransformText rpc
[POST] /v1/transform-and-split To call with REST the TransformAndSplitText rpc

gRPC envoy proxy

This envoy proxy is running the envoy.filters.http.grpc_web filter to enable frontend application to interact using gRPC-web.

The proxy configuration is located in envoy folder.

You can access it on localhost:9999 to interact with it, and use the frontend client to test from a web application.