README
¶
Mithril Configuration & Monitoring Example
This example demonstrates Phase 13: Configuration & Settings and the new monitoring capabilities for queues and cron jobs.
Features Demonstrated
Configuration System
- App Configuration: Complete application settings with environment variable support
- Database Configuration: Multi-database support with connection pooling
- Cache Configuration: Memory and Redis cache settings
- Environment-based: Different settings for dev/staging/prod
Monitoring System
- System Dashboard: Real-time system overview at
/monitor - Queue Monitor: Queue statistics and worker status at
/monitor/queue/dashboard - Cron Monitor: Scheduled task monitoring at
/monitor/cron/dashboard - Health Checks: System health endpoints
- JSON APIs: Machine-readable monitoring data
Configuration
Environment Variables
Copy env.example to .env and modify as needed:
cp env.example .env
Key Configuration Areas
Application Settings
APP_NAME: Application nameAPP_ENV: Environment (development/staging/production)APP_DEBUG: Debug modeAPP_TIMEZONE: Application timezoneAPP_MAX_FILE_UPLOAD_SIZE: Max file upload size in bytes
JWT & Security
JWT_SECRET: JWT signing secretJWT_EXPIRY: Token expiration timeHASHING_ALGORITHM: Password hashing (bcrypt/argon2)CSRF_SECRET: CSRF protection secret
Database
DB_DRIVER: Database driver (postgres/mysql/sqlite)DB_HOST,DB_PORT: Database connectionDB_MAX_OPEN_CONNS: Connection pool sizeDB_MIGRATION_PATH: Migration files location
Cache & Queue
CACHE_DRIVER: Cache driver (memory/redis)QUEUE_DRIVER: Queue driver (memory/redis/rabbitmq)REDIS_HOST,REDIS_PORT: Redis connection
Running the Example
# Build and run
go run main.go
# Or build first
go build -o mithril-config
./mithril-config
API Endpoints
Configuration Endpoints
GET /config- Complete configurationGET /config/app- Application settingsGET /config/database- Database settingsGET /config/cache- Cache settingsGET /env- Environment information
Monitoring Endpoints
GET /monitor- Main monitoring dashboardGET /monitor/system- System statistics (JSON)GET /monitor/queue- Queue statistics (JSON)GET /monitor/queue/dashboard- Queue monitoring UIGET /monitor/cron- Cron statistics (JSON)GET /monitor/cron/dashboard- Cron monitoring UIGET /monitor/health- Health checkGET /health- Simple health check
Documentation
GET /docs- Swagger UI documentation
Monitoring Features
System Dashboard (/monitor)
- Application overview
- System health status
- Database, cache, and storage status
- Real-time statistics
- Navigation to specialized monitors
Queue Monitor (/monitor/queue/dashboard)
- Active queues and job counts
- Worker status and performance
- Failed job tracking
- Real-time updates every 5 seconds
- Queue-specific statistics
Cron Monitor (/monitor/cron/dashboard)
- Scheduled task overview
- Task execution history
- Success/failure rates
- Next run times
- Real-time updates every 10 seconds
Configuration Examples
Development Environment
APP_ENV=development
APP_DEBUG=true
CACHE_DRIVER=memory
QUEUE_DRIVER=memory
DB_DRIVER=sqlite
Production Environment
APP_ENV=production
APP_DEBUG=false
CACHE_DRIVER=redis
QUEUE_DRIVER=rabbitmq
DB_DRIVER=postgres
REDIS_HOST=redis-cluster.internal
Staging Environment
APP_ENV=staging
APP_DEBUG=false
CACHE_DRIVER=redis
QUEUE_DRIVER=redis
DB_DRIVER=postgres
Integration with Generated Projects
When you create a new Mithril project with mithril new project-name, the configuration system is automatically integrated:
- Environment files:
.env.exampletemplate is created - Configuration loading: App automatically loads from environment
- Monitoring setup: All monitoring endpoints are registered
- Health checks: Ready for Kubernetes probes
Next Steps
This example shows the foundation for:
- Phase 14: Utilities & Helpers (hashing, encryption, pagination)
- Phase 15: GraphQL Support (optional add-on)
- Phase 16: Docker & Kubernetes (containerization)
- Phase 17: CI/CD & Automation (GitHub Actions)
The monitoring system provides the foundation for production observability and the configuration system enables environment-specific deployments.
Documentation
¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.