Skip to content

Add tenant-id integration and improve asyncio handling#1

Merged
faizanazim11 merged 5 commits intomainfrom
feat/tenant-integration
Mar 15, 2025
Merged

Add tenant-id integration and improve asyncio handling#1
faizanazim11 merged 5 commits intomainfrom
feat/tenant-integration

Conversation

@faizanazim11
Copy link
Copy Markdown
Contributor

Introduce tenant-id integration by fetching it from cookies in FastAPI. Update asyncio event loop handling to use get_running_loop and cancel outstanding tasks for better performance.

Added tenant-id integration. as of now taking default implementation to fetch tenant-id from cookies of fastapi.
@faizanazim11 faizanazim11 self-assigned this Mar 15, 2025
@faizanazim11 faizanazim11 added the enhancement New feature or request label Mar 15, 2025
@faizanazim11 faizanazim11 requested a review from Copilot March 15, 2025 01:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the integration to use tenant_id instead of project_id and improves the asyncio event loop handling to cancel outstanding tasks more robustly. The key changes include:

  • Replacing project_id with tenant_id throughout the codebase.
  • Updating asyncio handling to use asyncio.get_running_loop along with improved cancellation of tasks.
  • Bumping the package version and updating dependency revisions (e.g. ruff) for enhanced performance and integration.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sql_db_utils/declarative_utils.py Renamed project_id to tenant_id and updated synchronous asyncio logic.
sql_db_utils/asyncio/declarative_utils.py Renamed project_id to tenant_id and improved asynchronous cancellation.
sql_db_utils/version.py Updated version from 1.0.0 to 1.0.1.
sql_db_utils/asyncio/session_management.py Renamed project_id to tenant_id and updated type annotations.
sql_db_utils/session_management.py Renamed project_id to tenant_id and updated caching and engine logic.
sql_db_utils/constants.py Updated enum base classes to use StrEnum directly.
.pre-commit-config.yaml Updated ruff revision to a newer version.
sql_db_utils/config.py Removed Redis config in all export.
Comments suppressed due to low confidence (1)

sql_db_utils/asyncio/declarative_utils.py:98

  • Calling loop.stop() within _get_declarative_module may stop the event loop unexpectedly, affecting other asynchronous operations. Consider removing or refactoring this call to manage loop termination in a more controlled manner.
loop.call_soon_threadsafe(loop.stop)

@faizanazim11 faizanazim11 requested a review from Copilot March 15, 2025 01:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors existing code to replace the use of "project_id" with "tenant_id" for multi-tenant support and improves asyncio event loop handling for graceful cancellation of pending tasks. Key changes include:

  • Renaming function parameters and variables from project_id to tenant_id across multiple modules.
  • Updating asyncio shutdown procedures to use get_running_loop() and properly cancel outstanding tasks.
  • Adjusting configuration and session management code to align with the tenant-id logic.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sql_db_utils/asyncio/declarative_utils.py Refactored tenant-id usage and updated asynchronous cancellation logic.
sql_db_utils/declarative_utils.py Similar tenant-id refactor and updated cancellation logic in synchronous context.
sql_db_utils/version.py Version bump from 1.0.0 to 1.0.1.
sql_db_utils/asyncio/session_management.py Replaced project_id with tenant_id and updated cookie parameter.
sql_db_utils/session_management.py Similar tenant-id updates in synchronous session management.
sql_db_utils/constants.py Minor adjustment to enum class declaration.
.pre-commit-config.yaml Updated ruff-pre-commit version.
sql_db_utils/config.py Removed RedisConfig from public exports.

@faizanazim11 faizanazim11 merged commit ebeaaa2 into main Mar 15, 2025
1 check passed
@faizanazim11 faizanazim11 deleted the feat/tenant-integration branch March 15, 2025 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants