Skip to content

Microservice written in Go for delivery of notifications, based on the Flash Framework with Hexagonal Architecture.

Notifications You must be signed in to change notification settings

flash-go/notifications-service

Repository files navigation

notifications-service

Microservice written in Go for delivery of notifications, based on the Flash Framework with Hexagonal Architecture.

Features

  • Communication protocols
    • HTTP
  • Support E-Mail transport
    • Flexible email management
    • Dynamic email generation based on templates
    • Supported providers
      • smtp.bz

Setup

1. Install Task

go install github.com/go-task/task/v3/cmd/task@latest

2. Create .env files

task env

3. Setup .env.server

Environment Variable Description
CONSUL_ADDR Full address (host:port) of the Consul agent (e.g., localhost:8500).
CONSUL_CA_CRT Base64 CA certificate file used to verify the Consul server's TLS certificate.
CONSUL_CLIENT_CRT Base64 client certificate file used for mTLS authentication with Consul.
CONSUL_CLIENT_KEY Base64 private key corresponding to CONSUL_CLIENT_CRT for mTLS authentication.
CONSUL_INSECURE_SKIP_VERIFY If set to true, disables TLS certificate verification (not recommended for production).
CONSUL_TOKEN Consul ACL token for authenticating requests to the Consul agent or server.
SERVICE_NAME Name used to register the service in Consul.
SERVICE_HOST Host address under which the service is accessible for Consul registration.
SERVICE_PORT Port number under which the service is accessible for Consul registration.
SERVER_HOST Host address the HTTP server should bind to (e.g., 0.0.0.0).
SERVER_PORT Port number the HTTP server should listen on (e.g., 8080).
LOG_LEVEL Logging level. See the log level table for details.

Log Levels

Level Value Description
Trace -1 Fine-grained debugging information, typically only enabled in development.
Debug 0 Detailed debugging information helpful during development and debugging.
Info 1 General operational entries about what's going on inside the application.
Warn 2 Indications that something unexpected happened, but the application continues to work.
Error 3 Errors that need attention but do not stop the application.
Fatal 4 Critical errors causing the application to terminate.
Panic 5 Severe errors that will cause a panic; useful for debugging crashes.
NoLevel 6 No level specified; used when level is not explicitly set.
Disabled 7 Logging is turned off entirely.

4. Setup .env.migrate

Environment Variable Description
CONSUL_ADDR Full address (host:port) of the Consul agent (e.g., localhost:8500).
CONSUL_CA_CRT Base64 CA certificate file used to verify the Consul server's TLS certificate.
CONSUL_CLIENT_CRT Base64 client certificate file used for mTLS authentication with Consul.
CONSUL_CLIENT_KEY Base64 private key corresponding to CONSUL_CLIENT_CRT for mTLS authentication.
CONSUL_INSECURE_SKIP_VERIFY If set to true, disables TLS certificate verification (not recommended for production).
CONSUL_TOKEN Consul ACL token for authenticating requests to the Consul agent or server.
SERVICE_NAME The name of the service in Consul used to retrieve database connection configuration.

5. Setup .env.seed

Environment Variable Description
CONSUL_ADDR Full address (host:port) of the Consul agent (e.g., localhost:8500).
CONSUL_CA_CRT Base64 CA certificate file used to verify the Consul server's TLS certificate.
CONSUL_CLIENT_CRT Base64 client certificate file used for mTLS authentication with Consul.
CONSUL_CLIENT_KEY Base64 private key corresponding to CONSUL_CLIENT_CRT for mTLS authentication.
CONSUL_INSECURE_SKIP_VERIFY If set to true, disables TLS certificate verification (not recommended for production).
CONSUL_TOKEN Consul ACL token for authenticating requests to the Consul agent or server.
SERVICE_NAME Name used to register the service in Consul.
OTEL_COLLECTOR_GRPC Address of the OpenTelemetry Collector for exporting traces via gRPC.
OTEL_COLLECTOR_CA_CRT Base64 ca.crt of the OpenTelemetry Collector.
OTEL_COLLECTOR_CLIENT_CRT Base64 client.crt of the OpenTelemetry Collector.
OTEL_COLLECTOR_CLIENT_KEY Base64 client.key of the OpenTelemetry Collector.
POSTGRES_HOST Hostname or IP address of the PostgreSQL database server.
POSTGRES_PORT Port number on which the PostgreSQL database server is listening.
POSTGRES_USER Username used to connect to the PostgreSQL database.
POSTGRES_PASSWORD Password used to authenticate with the PostgreSQL database.
POSTGRES_DB Name of the PostgreSQL database to connect to.
SMTP_BZ_API_KEY API key for smtp.bz service.

6. Run seed

task seed

Run

task

View Swagger docs

http://[SERVER_HOST]:[SERVER_PORT]/swagger/index.html

Full list of commands

task -l

About

Microservice written in Go for delivery of notifications, based on the Flash Framework with Hexagonal Architecture.

Resources

Stars

Watchers

Forks

Packages

No packages published