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.
- Host: GitHub
- URL: https://github.com/msskowron/pricefetchermicro
- Owner: MSSkowron
- Created: 2022-12-19T21:21:55.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-28T13:50:08.000Z (over 3 years ago)
- Last Synced: 2025-01-09T11:56:00.491Z (over 1 year ago)
- Topics: docker, go, grpc, postgresql, rest-api
- Language: Go
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.