Rename project to ddns-service

This commit is contained in:
2026-01-18 14:32:41 +01:00
parent d0ac96bad8
commit 27fd8ab438
18 changed files with 61 additions and 61 deletions

64
src/ddns_service/app.py Normal file
View File

@@ -0,0 +1,64 @@
"""Application class - central dependency holder."""
import logging
import threading
import argon2
from .dns import DNSService
from .email import EmailService
from .models import init_database
from .ratelimit import RateLimiter
class Application:
"""
Central application state holder.
Holds configuration and all service instances.
"""
def __init__(self, config):
"""
Initialize application with configuration.
Args:
config: Configuration dictionary from TOML file.
"""
self.config = config
self.password_hasher = argon2.PasswordHasher()
self.shutdown_event = threading.Event()
# Service instances (initialized separately)
self.dns_service = None
self.email_service = None
self.rate_limiter = None
def init_database(self):
"""Initialize database connection."""
init_database(self.config)
logging.info("Database initialized")
def init_dns(self):
"""Initialize DNS service."""
self.dns_service = DNSService(self.config)
logging.info("DNS service initialized")
def init_email(self):
"""Initialize email service."""
self.email_service = EmailService(self.config)
logging.info("Email service initialized")
def init_rate_limiter(self):
"""Initialize rate limiter."""
self.rate_limiter = RateLimiter(self.config)
logging.info("Rate limiter initialized")
def signal_shutdown(self):
"""Signal the application to shut down."""
logging.info("Shutdown signaled")
self.shutdown_event.set()
def is_shutting_down(self):
"""Check if shutdown has been signaled."""
return self.shutdown_event.is_set()