♻️(backend) extract livekit API client creation to reusable utility
Create dedicated utility function for livekit API client initialization. Centralizes configuration logic including custom session handling for SSL verification. Improves code reuse across backend components that interact with LiveKit.
This commit is contained in:
committed by
aleb_the_flash
parent
2ef95aa835
commit
ae17fbdaa8
@@ -2,12 +2,10 @@
|
||||
|
||||
# pylint: disable=no-member
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
import aiohttp
|
||||
from asgiref.sync import async_to_sync
|
||||
from livekit import api as livekit_api
|
||||
|
||||
from ... import utils
|
||||
from ..enums import FileExtension
|
||||
from .exceptions import WorkerConnectionError, WorkerResponseError
|
||||
from .factories import WorkerServiceConfig
|
||||
@@ -30,14 +28,7 @@ class BaseEgressService:
|
||||
async def _handle_request(self, request, method_name: str):
|
||||
"""Handle making a request to the LiveKit API and returns the response."""
|
||||
|
||||
custom_session = None
|
||||
if not settings.LIVEKIT_VERIFY_SSL:
|
||||
connector = aiohttp.TCPConnector(ssl=False)
|
||||
custom_session = aiohttp.ClientSession(connector=connector)
|
||||
|
||||
lkapi = livekit_api.LiveKitAPI(
|
||||
session=custom_session, **self._config.server_configurations
|
||||
)
|
||||
lkapi = utils.create_livekit_client(self._config.server_configurations)
|
||||
|
||||
# ruff: noqa: SLF001
|
||||
# pylint: disable=protected-access
|
||||
|
||||
Reference in New Issue
Block a user