Refactor code structure for improved readability and maintainability
This commit is contained in:
23
app/core/services.py
Normal file
23
app/core/services.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""Global services container to avoid circular imports."""
|
||||
|
||||
from app.services.scheduler import SchedulerService
|
||||
|
||||
|
||||
class AppServices:
|
||||
"""Container for application services."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize the application services container."""
|
||||
self.scheduler_service: SchedulerService | None = None
|
||||
|
||||
|
||||
# Global service container
|
||||
app_services = AppServices()
|
||||
|
||||
|
||||
def get_global_scheduler_service() -> SchedulerService:
|
||||
"""Get the global scheduler service instance."""
|
||||
if app_services.scheduler_service is None:
|
||||
msg = "Scheduler service not initialized"
|
||||
raise RuntimeError(msg)
|
||||
return app_services.scheduler_service
|
||||
Reference in New Issue
Block a user