Giter Site home page Giter Site logo

grpc-spike's Introduction

Proof of concept for a simple gRPC setup with servers and clients written in multiple languages

Contents

Requirements

Go SDK

Go >= 1.6 has to be installed in your machine

go env GOPATH and go env GOBIN must point to directories in your filesystem. go env GOBIN must be part of your $PATH.

Easiest way to get this working is to set the following environment variables in your shell init scripts (.basrc, .zshrc, ...)

export GOPATH=$HOME
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN

This repository

mkdir -p $GOPATH/src/github.com/rodrigodiez
cd $GOPATH/src/github.com/rodrigodiez
git clone [email protected]:rodrigodiez/grpc-spike.git

Go packages

dep

Provides dependency management for the project

go get -u github.com/golang/dep/cmd/dep

grpc

Provides go grpc package

go get -u google.golang.org/grpc

proto-gen-go

Providers go code generator for grpc services and clients

go get -u github.com/golang/protobuf/protoc-gen-go

protoc-gen-grpc-gateway

Provides go code generator for grpc gateway

go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway

protoc-gen-swagger

Provides swagger files generator for grpc-gateway

go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

PHP

php >= 5.6 has to be installed in your machine

automake, autoconf (Mac Os)

Provides configuration tools for make (necessary to compile php plugin)

brew install automake autoconf

GRPC, C implementation, repository

Provides protocol Buffers compiler (protoc) and php code generator source code

mkdir -p $GOPATH/src/github.com/grpc/
cd $GOPATH/src/github.com/grpc/
git clone [email protected]:grpc/grpc.git

Docker

docker and docker-compose have to be installed in your machine

Build

cd $GOPATH/src/github.com/rodrigodiez/grpc-spike
make all

May take a while

  • Compiles php code generator plugin
  • Generates Go and php code from .proto files
  • Compiles Go server, client and gw applications
  • Build docker images to run php and nodejs code

Inspect the Makefile for more fine grained tasks

Run

Run one or the other...

# starts a GO server and a JSON gateway
docker-compose up

# starts a NODE server and a JSON gateway
docker-compose -f docker-compose-node.yml up

In a different terminal, experiment with the following operations...

add recording

# go
bin/client --command=add --recording "<name of the recording>"
# php
docker run -ti --rm --network grpcspike_default kobaltmusic/grpc-spike:php php bin/add.php "<name of the recording>"
# node
docker run -ti --rm --network grpcspike_default kobaltmusic/grpc-spike:node node add.js "name of the recording"
# gateway
curl -X POST http://localhost:8080/v1/recordings -d '{"recording": {"name": "name of the recording", "author": { "name": "HTTP/JSON"}}}'

list recordings

# go
bin/client --command=list
# php
docker run -ti --rm --network grpcspike_default kobaltmusic/grpc-spike:php php bin/list.php
# node
docker run -ti --rm --network grpcspike_default kobaltmusic/grpc-spike:node node list.js
# gateway
curl http://localhost:8080/v1/recordings

list recordings stream (1000ms delay) (delay only if go server, nodejs sleep requires python)

# go
bin/client --command=stream
# php
docker run -ti --rm --network grpcspike_default kobaltmusic/grpc-spike:php php bin/stream.php
# node
docker run -ti --rm --network grpcspike_default kobaltmusic/grpc-spike:node node stream.js

grpc-spike's People

Contributors

rodrigodiez avatar

Watchers

 avatar

Forkers

zhangyaxu

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.