A concurrent task processing system built in Go, designed to demonstrate safe worker-pool concurrency, RESTful API design, and clean application structure. The system allows clients to submit tasks, processes them asynchronously using a configurable worker pool, and exposes APIs to monitor task status and pool statistics. The application is containerized with Docker and uses PostgreSQL for persistent task storage.
- Asynchronous task processing using an idiomatic Go worker-pool pattern
- Safe concurrency with buffered channels, contexts, and graceful shutdown handling
- RESTful API built with Gin for HTTP routing and request handling
- Persistent task storage using PostgreSQL
- Database access and migrations managed with GORM
- Configurable application settings using Viper with support for YAML config files and environment variables
- Configurable task pool size and worker count
- Clear task state machine (pending, processing, completed, failed)
- Graceful shutdown ensuring in-flight tasks complete before exit
- Containerized application using Docker
- Local service orchestration with Docker Compose
- Clean, layered project structure separating handlers, services, repositories, and workers
- Unit tests covering handlers, services, and worker pool behavior
- Race-condition–safe design, verifiable with Go’s -race detector
cd to the project directory and run this command:
docker-compose up --build -dto stop all services:
docker-compose downto stop services and remove database volumes:
docker-compose down -vcurl -X POST "http://localhost:8080/api/v1/tasks" \
-H "Content-Type: application/json" \
-d '{
"title": "Process Data",
"description": "Process customer data for analytics"
}'curl -X GET "http://localhost:8080/api/v1/tasks/550e8400-e29b-41d4-a716-446655440000"curl -X GET "http://localhost:8080/api/v1/tasks"curl -X GET "http://localhost:8080/api/v1/pool/stats"- Create and Monitor a Task Script
- Create Multiple Tasks Script
- Test Pool Capacity Script
- Watch Pool Stats Script
- Watch Task Progress Script
go test ./test/...
go test ./test/... -racego test ./test/service -v
go test ./test/service -race -vgo test ./test/worker -v
go test ./test/worker -race -vgo test ./test/handler -v
go test ./test/handler -race -v