Commit fa936aa
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
- src/google/adk_community/sessions
- tests/unittests/sessions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
| 20 | + | |
0 commit comments