Coder Social home page Coder Social logo

rent-vs-buy-grpc-go's Introduction

Golang and gRPC rent-vs-buy calculator

Prerequisites:

  1. This project needs a working setup of Docker.
  2. This project needs a working setup of Docker-compose.
  3. This project needs a working setup of Go tools.
  4. You will need a working version of "protoc" compiler for changing ".proto" files, or adding new ".proto" files and compiling them into ".pb.go" files.

Setup instructions

Step 1:

To have the project working correctly, you should have an ".env" file, located in the root of the project. For this you could copy the ".env.example" file to ".env":

$ cp .env.example .env

Step 2:

You can (re)build ".proto" files using the following command:

$ make proto_gen

Step 3:

To spin up the gRPC server using docker, open up a terminal, change directory to the root of the project and run the following command:

$ make up

Step 4:

To shut down the gRPC server and stop the app container, run the following command:

$ make down

Step 5:

If you wish to run the gRPC server on your own machine, run the following command:

$ make run

Step 6:

To test the gRPC API, you need a grpc client. Installing "grpcurl" is recommended. To do so, run the following command:

$ go get github.com/fullstorydev/grpcurl/...
$ go install github.com/fullstorydev/grpcurl/cmd/grpcurl

This installs the "grpcurl" utility executable into your $GOPATH/bin directory. Make sure this directory is in your PATH environment variable, to be accessed from your terminal.

Step 6:

Now you can test the gRPC services. To do so, run the following command:

  • With empty request(It will calculate the response using default options):
$ grpcurl -plaintext localhost:9000 v1.breakeven.BreakevenService/CalcBreakeven
  • With request:
$ grpcurl -plaintext -d '{"houseValue": 750000, "downPayment": 10, "propertyTaxRate": 1, "propertyTransferTaxRate": 1, "livingYears": 30, "mortgageInterestRate": 1, "mortgageTerm": 30, "monthlyCommonCost": 300}' localhost:9000 v1.breakeven.BreakevenService/CalcBreakeven

Tips

  • The "-d" flag is for your input request. You can form your request into a JSON string to test the services, as shown above.
  • The "-plaintext" flag is for insecure connections, when the gRPC server does not accept TLS.

Considerations

  • No tests yet! The reason for this was the lack of time and to respect the deadline.

TODO

  • Tests

rent-vs-buy-grpc-go's People

Stargazers

 avatar

Watchers

Ayub avatar

Forkers

kazemibardia132

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.