Categorygithub.com/fdemchenko/exchanger
module
0.0.0-20240727161339-a23e0e9d1532
Repository: https://github.com/fdemchenko/exchanger.git
Documentation: pkg.go.dev

# README

Exchange rate API

GET /rate - get USD to UAH exchange rate

POST /subscribe - subscribe to exchange rate update (send application/x-www-form-urlencoded email address)

POST /unsubscribe - delete exchange rate subscription (send application/x-www-form-urlencoded email address)

Running application

Edit docker-compose.yml file and put your SMTP credentials, to be able to send updates to subscribers

To start http server and PostgreSQL service run: - docker compose up

Metrics

Application (each service at :8080/metrics in Prometheus format) exposes different metrics such as:

  • total_email_sent
  • customers_created_total{success=true|false}
  • requests_total{method, path, status}
  • total_subscribers{success=true|false}
  • total_unsubscribers{success=true|false}

And other go_* and process_* metrics

To create metrics dashboards and view graphical representation go to localhost:3000 (Grafana)

Alerts

  • total_subscribers{success=true} != customers_created_total{success=true} (Error in interservice communication, SAGA does not work)
  • Anomaly rising of total_unsubscribers metric
  • go_max_fd - go_total_fd < 100 (Small amount of open free file descriptors, connections leaks)
  • total_email_sent < total_subscribers - total_unsubsribers (Not all emails were sent)

Architecture

alt text

Tests

To run unit tests for whole applicaton run go test -short ./... Run go test ./... to run all tests, including integration ones (require docker installed on your system)

TODO

  • Graceful server shutdown
  • SSL encryption
  • Parallel emails sending

# Packages

No description provided by the author
No description provided by the author
No description provided by the author