✨(backend) introduce general recording worker concepts
Introducing a new worker service architecture. Sorry for the long commit. This design adheres to several key principles, primarily the Single Responsibility Principle. Dependency Injection and composition are prioritized over inheritance, enhancing modularity and maintainability. Interactions between the backend and external workers are encapsulated in classes implementing a common `WorkerService` interface. I chose Protocol over an abstract class for agility, aligning closely with static typing without requiring inheritance. Each `WorkerService` implementation can independently manage recordings according to its specific requirements. This flexibility ensures that adding a new worker service, such as for LiveKit, can be done without any change to existing components. Configuration management is centralized in a single `WorkerServiceConfig` class, which loads and provides all settings for different worker implementations, keeping configurations organized and extensible. The worker service class itself handles accessing relevant configurations as needed, simplifying the configuration process. A basic dictionary in Django settings acts as a factory, responsible for instantiating the correct worker service based on the client's request mode. This approach aligns with Django development conventions, emphasizing simplicity. While a full factory class with a builder pattern could provide future flexibility, YAGNI (You Aren't Gonna Need It) suggests deferring such complexity until it’s necessary. At the core of this design is the worker mediator, which decouples worker service implementations from the Django ORM and manages database state according to worker state. The mediator is purposefully limited in responsibility, handling only what’s essential. It doesn’t instantiate worker services directly; instead, services are injected via composition, allowing the mediator to manage any object conforming to the `WorkerService` interface. This setup preserves flexibility and maintains a clear separation of responsibilities. The factory create worker services, the mediator runs it. (sorry for this long commit)
This commit is contained in:
committed by
aleb_the_flash
parent
7278613b20
commit
f6f1222f47
@@ -57,6 +57,7 @@ dependencies = [
|
||||
"whitenoise==6.7.0",
|
||||
"mozilla-django-oidc==4.0.1",
|
||||
"livekit-api==0.7.0",
|
||||
"aiohttp==3.10.10",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
||||
Reference in New Issue
Block a user