A scalable and reliable webhook delivery service that handles event notifications with fair queueing and retry mechanisms.
- Docker
- Docker Compose
That's it! You don't need Go, PostgreSQL, or any other dependencies installed locally.
# Make the script executable (Unix-like systems)
chmod +x start.sh
# Start the service
./start.sh# Start the services
docker compose up --build
# Or run in detached mode
docker compose up -d --build
# View logs
docker compose logs -f
# Stop services
docker compose downAll configuration is done through environment variables. You can override the defaults by creating or modifying the .env file in the project root. Here are the key configuration options:
# HTTP server configuration
PORT=8080
APP_ENV=local
# Database configuration
WS_DB_HOST=localhost
WS_DB_PORT=5432
WS_DB_DATABASE=webhook_service
WS_DB_USERNAME=admin
WS_DB_PASSWORD=password1234
WS_DB_SCHEMA=public
# Worker and queue configuration
QUEUE_BUFFER_SIZE=100
MIN_WORKERS=5
MAX_WORKERS=20
MIN_REQUEST_WORKERS=5
MAX_REQUEST_WORKERS=20
REQUEST_BUFFER_SIZE=1000
# Retry configuration
INITIAL_DELAY=1s
MAX_DELAY=10s
MAX_RETRIES=3
SHUTDOWN_TIMEOUT=10sNote: When running with Docker Compose, the database host is automatically set to psql_ws (the service name in docker-compose.yml).
Once the service is running, you can test it using curl:
# Health check
curl http://localhost:8080/health
# Send a test webhook event
curl -X POST http://localhost:8080/webhooks/events \
-H "Content-Type: application/json" \
-d '{
"event_name": "subscriber.created",
"event_time": "2024-03-19T14:15:22Z",
"webhook_id": "test-webhook-id",
"subscriber": {
"id": "sub123",
"status": "active",
"email": "[email protected]",
"source": "manual",
"first_name": "John",
"last_name": "Doe",
"segments": [],
"custom_fields": {},
"optin_ip": "127.0.0.1",
"optin_timestamp": "2024-03-19T14:15:22Z",
"created_at": "2024-03-19T14:15:22Z"
}
}'For detailed information about the system architecture, components, and design decisions, please see the Architecture Documentation.
Key architectural features:
- Reliability: Implements retry mechanism with exponential backoff
- Scalability: Uses worker pools and is horizontally scalable
- Fairness: Implements fair queueing to prevent large customers from flooding the system
For information about benchmarking the webhook service, including performance testing methodologies, tools, and build instructions, please see the Benchmarking Documentation.
cmd/: Application entry pointsapp/: Main webhook service applicationbenchmark/: Performance testing toolsmockserver/: Mock webhook target server
internal/: Internal packagesconfig/: Application configurationdatabase/: Database connection and migrationsmodel/: Data models and validationrepository/: Data access layerserver/: HTTP server and request routingservice/: Business logic and worker pools
scripts/: Utility scriptsstart.sh: Convenience script for starting the servicedocker-compose.yml: Docker Compose configurationDockerfile: Docker build configuration.env: Environment variable configuration
This project is licensed under the MIT License - see the LICENSE file for details.