Skip to content

feat: Support for push config db persistence #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kthota-g
Copy link
Collaborator

@kthota-g kthota-g commented Jun 4, 2025

[WIP] support for DB backed stores

zboyles and others added 3 commits June 2, 2025 11:24
…) (#106)

* feat: postgresql task store

* feat: postgresql task store

* feat: postgresql task store

* feat: postgresql task store

* feat: postgresql task store

* Update check-spelling metadata

* feat: postgresql task store

* Refactor TaskStore to be database-agnostic using SQLAlchemy

This commit replaces the PostgreSQL-specific TaskStore with a generic
`DatabaseTaskStore` that leverages SQLAlchemy for database interactions.
This change allows your A2A server to support multiple database backends,
including SQLite, PostgreSQL, and MySQL.

Key changes include:
- Definition of a SQLAlchemy model `TaskModel` for storing task data.
- Implementation of `DatabaseTaskStore` that uses the `TaskStore` interface
  and SQLAlchemy for CRUD operations.
- Update of example application configurations to use `DatabaseTaskStore`
  when a `DATABASE_URL` environment variable is provided, defaulting to
  `InMemoryTaskStore` otherwise.
- Creation of parameterized unit tests for `DatabaseTaskStore`, designed
  to run against SQLite, PostgreSQL, and MySQL to ensure compatibility.
- Removal of the old `PostgreSQLTaskStore` and its specific tests.
- Addition of necessary dependencies: `sqlalchemy`, `aiosqlite`, `aiomysql`.

The new implementation makes the task persistence layer more flexible
and extensible, allowing you to choose a database backend that best
suits your needs.

* feat: postgresql task store

* feat: postgresql task store

* feat: postgresql task store

* feat: postgresql task store

* feat: postgresql task store

* Update check-spelling metadata

* feat: postgresql task store

* Refactor TaskStore to be database-agnostic using SQLAlchemy

This commit replaces the PostgreSQL-specific TaskStore with a generic
`DatabaseTaskStore` that leverages SQLAlchemy for database interactions.
This change allows your A2A server to support multiple database backends,
including SQLite, PostgreSQL, and MySQL.

Key changes include:
- Definition of a SQLAlchemy model `TaskModel` for storing task data.
- Implementation of `DatabaseTaskStore` that uses the `TaskStore` interface
  and SQLAlchemy for CRUD operations.
- Update of example application configurations to use `DatabaseTaskStore`
  when a `DATABASE_URL` environment variable is provided, defaulting to
  `InMemoryTaskStore` otherwise.
- Creation of parameterized unit tests for `DatabaseTaskStore`, designed
  to run against SQLite, PostgreSQL, and MySQL to ensure compatibility.
- Removal of the old `PostgreSQLTaskStore` and its specific tests.
- Addition of necessary dependencies: `sqlalchemy`, `aiosqlite`, `aiomysql`.

The new implementation makes the task persistence layer more flexible
and extensible, allowing you to choose a database backend that best
suits your needs.

* Refactor project to support multiple database backends

This commit introduces optional dependencies for PostgreSQL, MySQL, and SQLite support in the A2A SDK. Key changes include:
- Addition of optional dependencies in `pyproject.toml` for database drivers.
- Updates to example applications to demonstrate installation and usage with different databases.
- Refactoring of task management to utilize a generic `DatabaseTaskStore` for improved flexibility.
- Enhancements to the README for clearer instructions on database support.

These changes enhance the SDK's versatility, allowing users to choose their preferred database backend.

* Add drivername, aiomysql, and DSNs to the list of expected words in the spelling action

* GitHub Actions installs SQL dependencies for tests and database tests gracefully skip when SQLAlchemy isn't installed locally

* feat(db): refactor database backend to be database-agnostic

This allows users to choose their preferred database backend (PostgreSQL, MySQL, SQLite) while maintaining full compatibility and proper type safety.

- Replace PostgreSQL-specific JSONB with generic JSON type in models
- Implement SQLAlchemy 2.0 best practices with Mapped types and TypeDecorator
- Add configurable table name support via create_task_model() factory
- Updated metadata field mapping between Pydantic and SQLAlchemy using declared_attr
- Add comprehensive tests for metadata field mapping including complex nested data
- Update GitHub Actions to install SQL dependencies for tests
- Add pytest.importorskip to gracefully skip database tests when SQLAlchemy not installed
- Fix test_types.py to use 'id' instead of 'taskId' for JSON-RPC requests
- Add automatic cleanup of SQLite file::memory: files after tests
- Remove examples directory (moved to separate a2a-samples repo)
- Update pyproject.toml to remove workspace members reference and add `nox` for testing

* fix(models): correct variable name in TaskModel repr template

* fix: use typing_extensions for override decorator for Python 3.10 compatibility

The override decorator was added in Python 3.12. For compatibility with Python 3.10,
we import it from typing_extensions when not available in the typing module.

---------

Co-authored-by: MEUNIER Laurent <[email protected]>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Zac <[email protected]>
Co-authored-by: kthota-g <[email protected]>
@kthota-g kthota-g changed the title PushNotificationConfig DB backed model feat: Support for push config db persistence Jun 4, 2025
@pstephengoogle pstephengoogle mentioned this pull request Jun 6, 2025
4 tasks
Base automatically changed from sql-support to main July 1, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants