FastAPI dependency to get the async ClickHouse client. This allows for proper dependency injection and easier testing. Returns: AsyncClient: The async ClickHouse client instance
()
| 81 | |
| 82 | |
| 83 | async def get_async_clickhouse(): |
| 84 | """ |
| 85 | FastAPI dependency to get the async ClickHouse client. |
| 86 | This allows for proper dependency injection and easier testing. |
| 87 | |
| 88 | Returns: |
| 89 | AsyncClient: The async ClickHouse client instance |
| 90 | """ |
| 91 | global async_clickhouse |
| 92 | |
| 93 | # Check again inside the lock to prevent race conditions |
| 94 | if async_clickhouse is None: |
| 95 | async with _async_clickhouse_lock: |
| 96 | # Check again inside the lock to prevent race conditions |
| 97 | if async_clickhouse is None: |
| 98 | async_clickhouse = await get_async_client(**ConnectionConfig.to_connection_dict()) |
| 99 | return async_clickhouse |
| 100 | |
| 101 | |
| 102 | # Annotated dependencies for better type hinting |
no test coverage detected
searching dependent graphs…