google / google/adk-python-community

feat: Add BufferedFirestoreSessionService (batched, buffered Firestore session backend)

オープン
#159 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
182
フォーク
75
PR マージ指標
30日以内にマージされた PR はありません

説明

## What this is

ADK already ships a Firestore session service (`google.adk.integrations.firestore.FirestoreSessionService`). It works well, but it does one Firestore transaction per event — so if 10 messages fire 10 events, that's 10 separate writes, each touching the session document to bump its revision.

This adds a `BufferedFirestoreSessionService` to the community package that holds events in memory and flushes them all in a **single transaction** when the buffer fills up (or on a timer, or on shutdown). The session document gets updated once instead of 10 times, and the state docs get merged once.

## When to use it

You want this if:
- You're on a budget and Firestore costs matter (fewer writes = lower bill)
- Your service runs stably and you can afford to lose the last few seconds of events if it crashes

You want the builtin instead if:
- You need every event durable the moment it happens
- You're running in an environment where the process can be killed without warning

Both services use the same Firestore layout, so they're compatible with each other's data.

## What's in the PR

- `BufferedFirestoreSessionService` in `google.adk_community.sessions`
- Configurable buffer size, flush interval, retry behaviour
- `durable_mode=True` flag to fall back to per-event writes (same as builtin)
- `flat_layout=True` option for a flat `root_collection/{session_id}` layout instead of the default ADK nested path
- All collection names configurable if your Firestore uses a custom structure
- 20 unit tests, no external dependencies
- New `[firestore]` optional extra (`google-cloud-firestore>=2.11,<3`, matching ADK's own constraint)

PR: #160

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

提案されている google.adk_community.sessions エントリーポイントと併せて PR #160 を確認してください。説明されている 20 個のユニットテストと Firestore のオプショナル extra を確認し、その後、buffered、timer、shutdown、durable-mode、layout、collection、retry の各動作が issue と一致していることを検証してから、作業完了と判断してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
google-cloud, python
領域
database
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。