- Provides centralized dependency container for shared application resources
- Manages database connection pool and cache connection lifecycle
- Integrates configuration settings and batch job processing services
- Ensures consistent resource access patterns across the application
- Supports both explicit construction and convenience constructors for different environments
- Dependency Injection: Central container for all shared application resources
- Resource Management: Coordinates database pools, cache connections, and configuration
- Service Integration: Embeds batch job processing and background task services
- Compatibility Layer: Maintains backward compatibility with legacy Redis references
- Environment Adaptation: Provides different constructors for development vs production setups
AppState struct: Primary dependency container with all shared resources
- Cloneable design for efficient sharing across async tasks and handlers
- Multiple constructors:
new() for explicit setup, new_in_memory() for development
- Embedded services: BatchJobService integration with shared resource access
- Cache compatibility: Dual field names (
redis_conn, cache_conn) for migration support
- Resource Assembly: Combines database pool, cache connection, and configuration
- Service Initialization: Creates batch job service with shared resource access
- State Cloning: Efficient Arc-based sharing across application components
- Legacy Compatibility: Maintains multiple cache connection references during migration
- Development Setup: Simplified constructor for local development environments
- Database Layer: Contains database connection pool for all data access
- Cache System: Holds cache connection manager for all caching operations
- Configuration: Embedded application configuration for runtime behavior
- Batch Services: Integrated batch job processing with shared resource access
- All Handlers: Injected into every HTTP handler for resource access
- Background Tasks: Shared across monitoring, cleanup, and processing tasks
- Dependency Injection Container: Centralized resource management pattern
- Resource Sharing: Arc-based efficient resource sharing across async contexts
- Service Composition: Embedded service pattern with shared resource access
- Migration Support: Dual field names for gradual API migration
- Environment Flexibility: Multiple constructors for different deployment contexts
- Clone-Friendly Design: Efficient state sharing through reference counting