GithubHelp home page GithubHelp logo

exchange-rate-receiver's Introduction

Exchange Rate Receiver

Overview

Exchange Rate Receiver is a GRPC service that retrieves the USDT exchange rate from the Garantex exchange. It provides ask and bid prices along with a timestamp, and stores this information in a PostgreSQL database upon each request.

Features

  • GRPC method GetRates for retrieving USDT exchange rates from Garantex.
  • Stores the exchange rates with a timestamp in PostgreSQL.
  • Healthcheck method to check the service's health.
  • Graceful shutdown.

Requirements

  • Go 1.22 or higher
  • Docker and Docker Compose
  • PostgreSQL

Configuration

Configuration parameters can be managed using environment variables or command-line flags. The following parameters are used:

  • DATABASE_URL: PostgreSQL connection string (postgres://user:password@localhost:5432/exchangerates?sslmode=disable)
  • GRPC_PORT: Port for the GRPC server (default: 50051)

Copy .env.example to .env in your local environment

Setup Instructions

1. Clone the repository

git clone https://github.com/yourusername/exchange-rate-receiver.git
cd exchange-rate-receiver

2. Build the application

make build

3. Build the Docker images and run the services using Docker Compose

docker-compose build
docker-compose up

4. Run the application

docker-compose run --rm app ./app

5. Run the tests

make test

Protobuf

Install

(MacOS) To install protoc run

brew install protobuf

Then download Go protobuf plugins

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

Generation

Navigate to the root directory of your project and run the following commands to generate the Go code from the protobuf definitions:

protoc --go_out=.. --go-grpc_out=.. proto/exchange_rate.proto

Running Locally

  1. Install dependencies:

    go mod download
  2. Build the application:

    cd cmd/server
    go build -o ../../exchange_rate-receiver
    cd ../..
  3. Run the application:

    ./exchange_rate-receiver

exchange-rate-receiver's People

Contributors

dmside avatar

Watchers

 avatar

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.