An open API service indexing awesome lists of open source software.

https://github.com/msskowron/pricefetchermicro

Microservice to fetch cryprocurrencies price written in Go.
https://github.com/msskowron/pricefetchermicro

docker go grpc postgresql rest-api

Last synced: about 2 months ago
JSON representation

Microservice to fetch cryprocurrencies price written in Go.

Awesome Lists containing this project

README

          

# PriceFetcherMicro

PriceFetcherMicro is a microservice written in Go to fetch cryprocurrencies price. \
Prices are currently hard coded in server.go file. There are currently two available: BTC and ETH. \
REST Server is listening on port 3000, while gRPC server is listening on port 4000.

## Technologies

- Go
- PostgreSQL
- Docker

## Requirements

We need to have Docker installed in order to run the application.

## Installation

`git clone https://github.com/MSSkowron/GoPriceFetcherMicro`

## How to run

```
cd GoPriceFetcherMicro
docker-compose up -d
```

## How to use it?

- ***REST Client*** \
We can use _Client_ struct from the _client_ package. \
_NewClient_ creates a new instance of the _Client_ struct. We only need to pass the server listening address. In this case it is ":3000". \
In order to fetch a price use _FetchPrice_ method on the client instance. \
Of course in order to fetch a price we can also make a HTTP request specyfing _ticker_ as a request's query parameter. \
For example: http://localhost:3000/?ticker=BTC \
JSON Response Body:
```json
{
"ticker": "string",
"price": "float64"
}
```

- ***gRPC Client*** \
We can use _proto.PriceFetcherClient_ struct from the _client_ package. \
_NewGRPCClient_ creates a new instance of the _proto.PriceFetcherClient_ struct. We only need to pass the server listening address. In this case it is ":4000". \
In order to fetch a price use _FetchPrice_ method on the _proto.PriceFetcherClient_ instance.