Skip to content

Commit fa936aa

Browse files
committed
feat(sessions): add BufferedFirestoreSessionService
Add a Firestore-backed session service that buffers events in memory and flushes them in a single transaction per session, collapsing the repeated session-doc/state-doc updates and per-event transactions from N to 1. Mirrors the data model of the builtin google.adk.integrations.firestore.FirestoreSessionService (collection hierarchy, app/user/session state scoping, optimistic concurrency via a revision field, idempotent event docs keyed by event.id) and adds: - in-memory per-session buffering with count/interval/explicit/shutdown flush - durable_mode to persist every event immediately - exponential backoff with jitter on retryable errors - start()/stop()/flush() ADK lifecycle hooks Gated behind the new optional [firestore] extra. Unit tests use an in-memory fake AsyncClient (no external services).
1 parent 396da17 commit fa936aa

4 files changed

Lines changed: 1325 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ changelog = "https://github.com/google/adk-python-community/blob/main/CHANGELOG.
3939
documentation = "https://google.github.io/adk-docs/"
4040

4141
[project.optional-dependencies]
42+
firestore = [
43+
"google-cloud-firestore>=2.11.0, <3.0.0", # For BufferedFirestoreSessionService
44+
]
4245
s3 = [
4346
"aioboto3>=13.0.0", # For S3ArtifactService
4447
]

src/google/adk_community/sessions/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Community session services for ADK."""
1616

17+
from .firestore_session_service import BufferedFirestoreSessionService
1718
from .redis_session_service import RedisSessionService
1819

19-
__all__ = ["RedisSessionService"]
20+
__all__ = ["BufferedFirestoreSessionService", "RedisSessionService"]

0 commit comments

Comments
 (0)