Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Elozzy/email-queue-microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

email-queue-microservice

πŸ“¬ Go Email Queue Microservice

A lightweight Go microservice that accepts email jobs over HTTP, queues them, and processes them asynchronously using a concurrent worker pool.


πŸš€ Features

  • βœ… HTTP API to enqueue email jobs
  • βœ… In-memory job queue with channels
  • βœ… Multiple concurrent workers
  • βœ… Simulated email delivery
  • βœ… Graceful shutdown on SIGINT/SIGTERM
  • βœ… Retry failed jobs (up to 3 times)
  • βœ… Dead Letter Queue (DLQ) for permanently failed jobs

πŸ“¦ Folder Structure

emailservice/ β”œβ”€β”€ main.go # Entry point β”œβ”€β”€ api/ β”‚ └── handler.go # HTTP handlers β”œβ”€β”€ queue/ β”‚ β”œβ”€β”€ config.go # Queue config β”‚ β”œβ”€β”€ interface.go # Job interface β”‚ β”œβ”€β”€ job.go # Job model β”‚ └── queue.go # Queue logic


βš™οΈ Configuration

Configuration is currently hardcoded in main.go:

cfg := queue.Config{
    QueueSize:   10,
    WorkerCount: 3,
}

## How to Run
go run main.go

## πŸ“¬ API Endpoints

### 1. `POST /send-email`

Enqueue a new email job.

#### πŸ“ Request Payload

```json
{
  "to": "[email protected]",
  "subject": "Welcome!",
  "body": "Thanks for signing up."
}

curl -X POST http://localhost:8080/send-email \
  -H "Content-Type: application/json" \
  -d '{
    "to": "[email protected]",
    "subject": "Welcome!",
    "body": "Thanks for signing up."
}'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages