/fibonacci-service

A service for returning a slice of a sequence of numbers from the Fibonacci series from x to y with a cache

Primary LanguageGo

FIBONACCI-SERVICE

GRPC-PORT: 7001

HTTP-PORT: 8080

REDIS-PORT: 6379

LOCAL CONFIGURATION

REQUIREMENTS

  • go 1.16
  • docker & docker-compose
  • redis
  • evans or bloom rpc
  • postman or curl

DOCKER

Build

docker-compose build

Run

docker-compose up

Go

Install REDIS

Create local-config.yaml file in config directory:

appconfig:
  ip: "0.0.0.0"
  grpc_port: "7001"
  http_port: "8080"
redis:
  db: 0
  host: "0.0.0.0"
  port: "6379"
  password: ""

Build

go build -o fibonacci-service cmd/main.go

Run

./fibonacci-service -config-path ./config/local-config.yaml

OR

go run cmd/main.go -config-path ./config/local-config.yaml

Testing GRPC

Install EVANS or BloomRPC

Run for evans with Makefile

make evans name=fibonacci port=7001

call FibonacciSequences

OR

Run for evans without Makefile

evans api/fibonacci.proto -p 7001

call FibonacciSequences

Testing HTTP

POST http://localhost:8080/api/v1/fibonacci_sequences

Body

{
  "x":5,
  "y":15
}

Install POSTMAN

OR

Run curl

curl -XPOST -H "Content-type: application/json" -d '{"x":5, "y":15}' 'http://localhost:8080/api/v1/fibonacci_sequences'