Skip to content

Repository files navigation

Go ADK Firestore Session Service

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.

Features

  • Implements the session.Service interface 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.

Getting Started

Prerequisites

  • Go 1.18 or later
  • A Google Cloud project with Firestore enabled
  • Application Default Credentials (ADC) configured for authentication

Installation

To use this service in your project, you can add it as a dependency:

go get github.com/ptone/adk-go-firestore-sessions

Usage

package 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.
}

Development

Running Tests

To run the tests, you will need to have the Firestore emulator running.

  1. Start the Firestore emulator:
gcloud beta emulators firestore start
  1. Set the FIRESTORE_EMULATOR_HOST environment variable:
export FIRESTORE_EMULATOR_HOST="localhost:8080"
  1. Run the tests:
go test -v

This is not a Google Product

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages