sessions

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package sessions implements google.golang.org/adk/session.Service backed by a SQLite database.

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionNotFound = errors.New("session not found")

ErrSessionNotFound is returned by mutating operations (SetTitle, Delete) when the targeted session does not exist, so callers can distinguish "nothing matched" from a successful no-op instead of reporting a false success. See issue #4.

Functions

This section is empty.

Types

type AppendHookFunc

type AppendHookFunc func(entry IndexEntry)

AppendHookFunc is the callback signature for SetAppendHook.

type IndexEntry

type IndexEntry struct {
	ID        string    `json:"id"`
	AppName   string    `json:"app_name"`
	UserID    string    `json:"user_id"`
	Title     string    `json:"title,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	LastAt    time.Time `json:"last_at"`
	MsgCount  int       `json:"msg_count"`
}

IndexEntry is the per-session metadata stored in the sessions table. Exposed so callers can list / search sessions without loading the full event history.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the SQLite-backed implementation of session.Service. Construct with New, hand the result to a runner.Config.

func New

func New(db *storage.DB) (*Service, error)

New wraps the given storage.DB database.

func (*Service) AppendEvent

func (s *Service) AppendEvent(ctx context.Context, sess session.Session, evt *session.Event) error

AppendEvent implements session.Service.

func (*Service) Create

Create implements session.Service.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, req *session.DeleteRequest) error

Delete implements session.Service.

func (*Service) Get

Get implements session.Service.

func (*Service) GetIndexEntry

func (s *Service) GetIndexEntry(ctx context.Context, appName, userID, sessionID string) (IndexEntry, bool, error)

GetIndexEntry returns the single IndexEntry for the named session.

func (*Service) List

List implements session.Service.

func (*Service) ListIndex

func (s *Service) ListIndex(ctx context.Context, appName, userID string) ([]IndexEntry, error)

ListIndex returns the index entries for every session of (appName, userID), sorted by LastAt descending.

func (*Service) MostRecent

func (s *Service) MostRecent(ctx context.Context, appName, userID string) (IndexEntry, bool, error)

MostRecent returns the index entry of the most recently used session.

func (*Service) SetAppendHook

func (s *Service) SetAppendHook(fn AppendHookFunc)

SetAppendHook installs (or clears, with nil) the AppendEvent callback.

func (*Service) SetTitle

func (s *Service) SetTitle(ctx context.Context, appName, userID, sessionID, title string) error

SetTitle updates the title of an existing session in the index. Returns ErrSessionNotFound when no row matches, so renaming a missing session surfaces an error instead of a silent success.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL