/gRPC-Calculator

This is a gRPC implementation of simple math tasks.

Primary LanguageGo

gRPC calculator

This is a gRPC implementation of simple math tasks. gRPC Calculator

Table of Contents
  1. About The Project
  2. Getting Started
  3. Further Possible Improvements

About The Project

An example gRPC calculator usage could look like the following. By running the server in a first shell user will be notified, that it is serving and waiting for calls from client. By starting the client in the second shell window, user will be prompted to enter a simple equation, f.e 1 + 2 . All allowed operations are +, -,* and /.

Built With

Getting Started

  1. Install dependencies

    go mod download
  2. In the first shell, start the server gServer.go

    go run gServer.go
  3. In the second shell, start the client gClient.go

    go run gClient.go
  4. Input some math operation

    1 + 1
    
    1000 / 13
    
    1000 * 13
    

Tests

For tests execution:

go test

To atumate the tests on every commit was added a Github Actions workflow.

Docker

Server

to run the server as a Dockerfile:

  1. Build the Dockerfile:

    docker build -t server -f server/Dockerfile .
  2. Run the container

    docker run -d -p 8080:8080 server
  3. Run the client.

    go run clien/gClient.go

Use container-container communication

Made according to this description

  1. Create network

    docker network create --driver bridge go-net
  2. Build and run the server. It is important to provide here a name for the server, so the client knows to whom he has to speak

    docker build -t server -f server/Dockerfile .
    docker run -d --network go-net  --name  server server
  3. Build and run the client via a shell script, that simulates a simple input.

    docker build -t client -f client/Dockerfile .
    docker run -i --log-driver=none -a stdin -a stdout -a stderr --network go-net -p 8080:8080 client

Further possible improvements

  • parsing complex strings
  • implementing additional math equations
  • ✅ error handling