Documentation
¶
Overview ¶
Package sessions implements google.golang.org/adk/session.Service backed by a SQLite database.
Index ¶
- Variables
- type AppendHookFunc
- type IndexEntry
- type Service
- func (s *Service) AppendEvent(ctx context.Context, sess session.Session, evt *session.Event) error
- func (s *Service) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error)
- func (s *Service) Delete(ctx context.Context, req *session.DeleteRequest) error
- func (s *Service) Get(ctx context.Context, req *session.GetRequest) (*session.GetResponse, error)
- func (s *Service) GetIndexEntry(ctx context.Context, appName, userID, sessionID string) (IndexEntry, bool, error)
- func (s *Service) List(ctx context.Context, req *session.ListRequest) (*session.ListResponse, error)
- func (s *Service) ListIndex(ctx context.Context, appName, userID string) ([]IndexEntry, error)
- func (s *Service) MostRecent(ctx context.Context, appName, userID string) (IndexEntry, bool, error)
- func (s *Service) SetAppendHook(fn AppendHookFunc)
- func (s *Service) SetTitle(ctx context.Context, appName, userID, sessionID, title string) error
Constants ¶
This section is empty.
Variables ¶
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 (*Service) AppendEvent ¶
AppendEvent implements session.Service.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error)
Create implements session.Service.
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, req *session.GetRequest) (*session.GetResponse, error)
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 ¶
func (s *Service) List(ctx context.Context, req *session.ListRequest) (*session.ListResponse, error)
List implements session.Service.
func (*Service) ListIndex ¶
ListIndex returns the index entries for every session of (appName, userID), sorted by LastAt descending.
func (*Service) MostRecent ¶
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.