This project provides a Go implementation of the session.Service for the Go Application Development Kit (ADK), using Google Cloud Firestore as the backend for session management.
- Implements the
session.Serviceinterface from the Go ADK. - Uses Google Cloud Firestore for persistent session storage.
- Supports application, user, and session-level state management.
- Provides an event-sourcing mechanism for session events.
- Go 1.18 or later
- A Google Cloud project with Firestore enabled
- Application Default Credentials (ADC) configured for authentication
To use this service in your project, you can add it as a dependency:
go get github.com/ptone/adk-go-firestore-sessionspackage main
import (
"context"
"log"
"cloud.google.com/go/firestore"
"github.com/ptone/adk-go-firestore-sessions"
)
func main() {
ctx := context.Background()
projectID := "your-gcp-project-id"
client, err := firestore.NewClient(ctx, projectID)
if err != nil {
log.Fatalf("Failed to create Firestore client: %v", err)
}
defer client.Close()
sessionService := firestore.NewService(client)
// Now you can use sessionService to create, get, and manage sessions.
}To run the tests, you will need to have the Firestore emulator running.
- Start the Firestore emulator:
gcloud beta emulators firestore start- Set the
FIRESTORE_EMULATOR_HOSTenvironment variable:
export FIRESTORE_EMULATOR_HOST="localhost:8080"- Run the tests:
go test -vThis is not a Google Product