Skip to content

fayvori/golang-email-microservice

Repository files navigation

Go-Microservices-Email

HTTP / gRPC / RabbitMQ Golang email microservice

📖 About

This is an email service for sending emails through grpc / http (grpc-gateway) and rabbitmq interfaces. With full cycle of DevOps methodologies (Ops repository)

⚙️ Technologies used:

  • GRPC - gRPC
  • GRPC-gateway - gRPC gateway for accessing either http and gRPC interfaces
  • Swagger - Swagger docs
  • RabbitMQ - RabbitMQ
  • Gorm - ORM library for Golang
  • Echo - High performance, minimalist Go web framework
  • Logrus - Structured, pluggable logger for Golang
  • viper - Go configuration with fangs
  • testify - Testing toolkit
  • Docker - Docker
  • Prometheus - Prometheus
  • Gomail - Simple and efficient package to send emails
  • Prometheus-go-client - Prometheus instrumentation library for Go applications
  • otel - otel client for Golang
  • Jaeger - otel Jaeger exporter

✅ Setup

First you need SMTP credentials for gomail, you can obtain it from various providers, for example Yahoo. Provider used as email delivery vendor for sending and receive email messages througth SMTP Protocol

Example config

smtp:
  Host: ""
  Port: 0
  User: ""
  Password: ""

logger:
  Mode: "prod"

metrics:
  Port: 8242

gateway:
  Port: 8192

jaeger:
  Host: localhost:14268

grpc:
  Port: 50001

rabbit:
  Host: "localhost"
  Port: 5672
  User: "guest"
  Password: "guest"
  QueueName: "test"
  ConsumePool: 2

database:
  Host: "localhost"
  Port: 5432
  User: "root"
  Password: "postgres"
  DbName: "mails_db"
  SslMode: "disable"

🏃 Running

For running you need a CONFIG variable setted in env, for test purposes you can edit values in config/config-local.yml and then export it with following command

export CONFIG=$(cat config/config-local.yml)

Local run

make compose_up
make run

Endpoints

Note: these endpoints valid with default config/config-local.yml file

gRPC gateway (REST)

http://localhost:8192/

gRPC Server

http://localhost:50001/

Metrics and Swagger

http://localhost:8242/metrics

Jaeger UI

http://localhost:16686/

Swagger

For running swagger execute the following command

make swagger

Credits

License

MIT License

Copyright (c) 2023 Ignat Belousov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Email microservices example on Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published