Implement async MemDBConnector with asyncio submodule structure#6
Conversation
|
@faizanazim11 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: faizanazim11 <20454506+faizanazim11@users.noreply.github.com>
Co-authored-by: faizanazim11 <20454506+faizanazim11@users.noreply.github.com>
…arios Co-authored-by: faizanazim11 <20454506+faizanazim11@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
@copilot
The implementation should keep the change for the end user minimal by moving all new async implementation to asyncio directory under project so the import should update like this:
sync:
from mem_db_utils import MemDBConnector
async:
from mem_db_utils.asyncio import MemDBConnector
Only logic to be added, documentation and test cases will be implemented in different issue.
|
@copilot - Please implement the changes requested in comment |
Co-authored-by: faizanazim11 <20454506+faizanazim11@users.noreply.github.com>
I've restructured the async implementation per your feedback. The import structure now works exactly as requested: Sync (unchanged): from mem_db_utils import MemDBConnectorAsync (new): from mem_db_utils.asyncio import MemDBConnectorChanges made:
This provides minimal changes for end users while cleanly separating sync and async implementations. Commit: 5b0a24c |
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive async support to the memory database utilities by implementing an async MemDBConnector class in a new asyncio submodule. The implementation provides full async/await compatibility while maintaining backward compatibility with the existing sync API.
Key changes:
- New async module structure: Creates
src/mem_db_utils/asyncio/with asyncMemDBConnectorimplementation - Comprehensive async testing: Adds unit and integration tests covering all async scenarios including concurrent connections
- Development dependency update: Adds
pytest-asynciofor async test support
Reviewed Changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/mem_db_utils/asyncio/__init__.py |
New async MemDBConnector implementation with Redis async support |
tests/test_async_connector.py |
Unit tests for async connector functionality and error handling |
tests/test_async_integration.py |
Integration tests for real async database connections |
pyproject.toml |
Adds pytest-asyncio dependency for async test support |
This PR adds comprehensive async support to the memory database utilities through a new async
MemDBConnectorclass in a dedicatedasynciosubmodule, providing full async/await compatibility while maintaining backward compatibility and minimal changes for end users.Key Features
Async MemDBConnector Class in asyncio Module
MemDBConnectorinterface with identical initialization and configurationasync connect()method usingredis.asyncio.from_urlfor async connectionsasync _sentinel()method usingredis.asyncio.Sentinelfor async Redis Sentinel support__slots__memory efficiency and configuration patternsMinimal Import Changes
Error Handling & Quality
aclose()supportImplementation Details
The implementation leverages the
redis.asynciomodule to provide native async support for Redis-compatible databases (Redis, Dragonfly, Valkey). The async connector uses the same configuration system and environment variables as the sync version, ensuring seamless integration.Changes:
src/mem_db_utils/asyncio/subdirectory with asyncMemDBConnectorimplementationsrc/mem_db_utils/__init__.pyremains unchanged (sync-only)mem_db_utils.asyncioProject Structure:
Testing:
The async implementation enables modern Python applications to use async/await patterns with memory databases while preserving all existing functionality for applications using the sync API. The modular structure keeps changes minimal for end users while providing a clean separation between sync and async implementations.
Fixes #3.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.