example-config

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 4 Imported by: 0

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 name
  • APP_ENV: Environment (development/staging/production)
  • APP_DEBUG: Debug mode
  • APP_TIMEZONE: Application timezone
  • APP_MAX_FILE_UPLOAD_SIZE: Max file upload size in bytes
JWT & Security
  • JWT_SECRET: JWT signing secret
  • JWT_EXPIRY: Token expiration time
  • HASHING_ALGORITHM: Password hashing (bcrypt/argon2)
  • CSRF_SECRET: CSRF protection secret
Database
  • DB_DRIVER: Database driver (postgres/mysql/sqlite)
  • DB_HOST, DB_PORT: Database connection
  • DB_MAX_OPEN_CONNS: Connection pool size
  • DB_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 configuration
  • GET /config/app - Application settings
  • GET /config/database - Database settings
  • GET /config/cache - Cache settings
  • GET /env - Environment information
Monitoring Endpoints
  • GET /monitor - Main monitoring dashboard
  • GET /monitor/system - System statistics (JSON)
  • GET /monitor/queue - Queue statistics (JSON)
  • GET /monitor/queue/dashboard - Queue monitoring UI
  • GET /monitor/cron - Cron statistics (JSON)
  • GET /monitor/cron/dashboard - Cron monitoring UI
  • GET /monitor/health - Health check
  • GET /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:

  1. Environment files: .env.example template is created
  2. Configuration loading: App automatically loads from environment
  3. Monitoring setup: All monitoring endpoints are registered
  4. 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

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL