Giter VIP home page Giter VIP logo

grpc-test's Introduction

Usage

Make sure these tools are available

Install protoc plugins

$ go get -u github.com/gogo/protobuf/protoc-gen-gogofaster
$ git clone https://github.com/grpc/grpc-web.git
$ cd grpc-web
$ sudo make install-plugin

Clone this repo and install dependencies

$ git clone https://github.com/devMYC/grpc-test.git
$ cd grpc-test
$ dep ensure  # or install go imports manually
$ yarn  # or `npm install`

Compile .proto file

$ protoc \
-I interfaces/ \
-I $GOPATH/src \
-I $GOPATH/src/github.com/gogo/protobuf/protobuf \
--gogofaster_out=plugins=grpc:interfaces \
--js_out=import_style=commonjs:interfaces \
--grpc-web_out=import_style=commonjs,mode=grpcweb:interfaces \
interfaces/healthcheck.proto

$ cd interfaces && go install && cd ..

Run the server

$ go run server.go  # listening on port 3000 by default

Or you can specify the port by

$ PORT=5000 go run server.go

At this point, you can test it with the node.js client from a new terminal window to see if it's working. Make sure the connection url in the client-node.js file is the ip:port your server is listening on.

Hope it works so we can move on...

Run the envoy proxy

Replace the $gRPC_SERVICE_IP in envoy.yaml with your server ip, also set the port_value on the next line to your server port if needed. Then run the following command:

$ docker-compose up -d

Send gRPC request from browser

$ export ENVOY_CONTAINER_IP=x.x.x.x  # default to localhost
$ yarn wds  # start the webpack-dev-server

Head over to http://localhost:8080/ and PING the server.

grpc-test's People

Contributors

devmyc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.