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
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@
sse
tagwords
vulnz
fernet

Check warning on line 40 in .github/actions/spelling/allow.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

Missing newline at eof. (no-newline-at-eof)
10 changes: 10 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
AUser
excinfo
fetchrow
fetchval
GVsb
initdb
isready
notif
otherurl
POSTGRES
postgres
postgresql
drivername
aiomysql
DSNs
1 change: 1 addition & 0 deletions .github/workflows/spelling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
cspell:sql/src/tsql.txt
cspell:terraform/dict/terraform.txt
cspell:typescript/dict/typescript.txt

check_extra_dictionaries: ""
only_check_changed_files: true
longest_word: "10"
16 changes: 15 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ jobs:
runs-on: ubuntu-latest

if: github.repository == 'google-a2a/a2a-python'
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: a2a_test
ports:
- 5432:5432

strategy:
matrix:
Expand All @@ -28,6 +37,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set postgres for tests
run: |
sudo apt-get update && sudo apt-get install -y postgresql-client
PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d a2a_test -f ${{ github.workspace }}/docker/postgres/init.sql
export POSTGRES_TEST_DSN="postgresql://postgres:postgres@localhost:5432/a2a_test"

- name: Install uv
run: |
Expand All @@ -38,7 +52,7 @@ jobs:
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Install dependencies
run: uv sync --dev
run: uv sync --dev --extra sql

- name: Run tests
run: uv run pytest
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ When you're working within a uv project or a virtual environment managed by uv,
uv add a2a-sdk
```

To install with database support:
```bash
# PostgreSQL support
uv add "a2a-sdk[postgresql]"

# MySQL support
uv add "a2a-sdk[mysql]"

# SQLite support
uv add "a2a-sdk[sqlite]"

# All database drivers
uv add "a2a-sdk[sql]"
```

### Using `pip`

If you prefer to use pip, the standard Python package installer, you can install `a2a-sdk` as follows
Expand All @@ -40,6 +55,21 @@ If you prefer to use pip, the standard Python package installer, you can install
pip install a2a-sdk
```

To install with database support:
```bash
# PostgreSQL support
pip install "a2a-sdk[postgresql]"

# MySQL support
pip install "a2a-sdk[mysql]"

# SQLite support
pip install "a2a-sdk[sqlite]"

# All database drivers
pip install "a2a-sdk[sql]"
```

## Examples

### [Helloworld Example](https://github.com/google-a2a/a2a-samples/tree/main/samples/python/agents/helloworld)
Expand Down
28 changes: 28 additions & 0 deletions docker/postgres/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3.8"

services:
postgres:
image: postgres:15-alpine
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=a2a_test
volumes:
- postgres_data:/var/lib/postgresql/data
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- a2a-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

volumes:
postgres_data:

networks:
a2a-network:
driver: bridge
8 changes: 8 additions & 0 deletions docker/postgres/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Create a dedicated user for the application
CREATE USER a2a WITH PASSWORD 'a2a_password';

-- Create the tasks database
CREATE DATABASE a2a_tasks;

GRANT ALL PRIVILEGES ON DATABASE a2a_test TO a2a;

27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ classifiers = [
"License :: OSI Approved :: Apache Software License",
]

[project.optional-dependencies]
postgresql = [
"cryptography>=45.0.3",
"sqlalchemy>=2.0.0",
"asyncpg>=0.30.0",
]
mysql = [
"cryptography>=45.0.3",
"sqlalchemy>=2.0.0",
"aiomysql>=0.2.0",
]
sqlite = [
"cryptography>=45.0.3",
"sqlalchemy>=2.0.0",
"aiosqlite>=0.19.0",
]
sql = [
"cryptography>=45.0.3",
"sqlalchemy>=2.0.0",
"asyncpg>=0.30.0",
"aiomysql>=0.2.0",
"aiosqlite>=0.19.0",
]

[project.urls]
homepage = "https://google-a2a.github.io/A2A/"
repository = "https://github.com/google-a2a/a2a-python"
Expand Down Expand Up @@ -64,8 +88,11 @@ style = "pep440"

[dependency-groups]
dev = [
"asyncpg-stubs>=0.30.1",
"datamodel-code-generator>=0.30.0",
"greenlet>=3.2.2",
"mypy>=1.15.0",
"nox>=2025.5.1",
"pytest>=8.3.5",
"pytest-asyncio>=0.26.0",
"pytest-cov>=6.1.1",
Expand Down
Loading