Documentation
¶
Index ¶
- type ConversationMetadata
- type ConversationStorage
- type ConversationSummary
- type PostgresConfig
- type PostgresStorage
- func (s *PostgresStorage) Close() error
- func (s *PostgresStorage) DeleteConversation(ctx context.Context, conversationID string) error
- func (s *PostgresStorage) Health(ctx context.Context) error
- func (s *PostgresStorage) ListConversations(ctx context.Context, limit, offset int) ([]ConversationSummary, error)
- func (s *PostgresStorage) LoadConversation(ctx context.Context, conversationID string) ([]domain.ConversationEntry, ConversationMetadata, error)
- func (s *PostgresStorage) SaveConversation(ctx context.Context, conversationID string, entries []domain.ConversationEntry, ...) error
- func (s *PostgresStorage) UpdateConversationMetadata(ctx context.Context, conversationID string, metadata ConversationMetadata) error
- type RedisConfig
- type RedisStorage
- func (s *RedisStorage) Close() error
- func (s *RedisStorage) DeleteConversation(ctx context.Context, conversationID string) error
- func (s *RedisStorage) Health(ctx context.Context) error
- func (s *RedisStorage) ListConversations(ctx context.Context, limit, offset int) ([]ConversationSummary, error)
- func (s *RedisStorage) LoadConversation(ctx context.Context, conversationID string) ([]domain.ConversationEntry, ConversationMetadata, error)
- func (s *RedisStorage) SaveConversation(ctx context.Context, conversationID string, entries []domain.ConversationEntry, ...) error
- func (s *RedisStorage) UpdateConversationMetadata(ctx context.Context, conversationID string, metadata ConversationMetadata) error
- type SQLiteConfig
- type SQLiteStorage
- func (s *SQLiteStorage) Close() error
- func (s *SQLiteStorage) DeleteConversation(ctx context.Context, conversationID string) error
- func (s *SQLiteStorage) Health(ctx context.Context) error
- func (s *SQLiteStorage) ListConversations(ctx context.Context, limit, offset int) ([]ConversationSummary, error)
- func (s *SQLiteStorage) LoadConversation(ctx context.Context, conversationID string) ([]domain.ConversationEntry, ConversationMetadata, error)
- func (s *SQLiteStorage) SaveConversation(ctx context.Context, conversationID string, entries []domain.ConversationEntry, ...) error
- func (s *SQLiteStorage) UpdateConversationMetadata(ctx context.Context, conversationID string, metadata ConversationMetadata) error
- type StorageConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConversationMetadata ¶
type ConversationMetadata struct { ID string `json:"id"` Title string `json:"title"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` MessageCount int `json:"message_count"` TokenStats domain.SessionTokenStats `json:"token_stats"` Model string `json:"model,omitempty"` Tags []string `json:"tags,omitempty"` Summary string `json:"summary,omitempty"` }
ConversationMetadata contains metadata about a conversation
type ConversationStorage ¶
type ConversationStorage interface { // SaveConversation saves a conversation with a unique ID SaveConversation(ctx context.Context, conversationID string, entries []domain.ConversationEntry, metadata ConversationMetadata) error // LoadConversation loads a conversation by its ID LoadConversation(ctx context.Context, conversationID string) ([]domain.ConversationEntry, ConversationMetadata, error) // ListConversations returns a list of conversation summaries ListConversations(ctx context.Context, limit, offset int) ([]ConversationSummary, error) // DeleteConversation removes a conversation by its ID DeleteConversation(ctx context.Context, conversationID string) error // UpdateConversationMetadata updates metadata for a conversation UpdateConversationMetadata(ctx context.Context, conversationID string, metadata ConversationMetadata) error // Close closes the storage connection Close() error // Health checks if the storage is healthy and reachable Health(ctx context.Context) error }
ConversationStorage defines the interface for persistent conversation storage
func NewStorage ¶
func NewStorage(config StorageConfig) (ConversationStorage, error)
NewStorage creates a new storage instance based on the provided configuration
type ConversationSummary ¶
type ConversationSummary struct { ID string `json:"id"` Title string `json:"title"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` MessageCount int `json:"message_count"` TokenStats domain.SessionTokenStats `json:"token_stats"` Model string `json:"model,omitempty"` Tags []string `json:"tags,omitempty"` Summary string `json:"summary,omitempty"` }
ConversationSummary contains summary information about a conversation
type PostgresConfig ¶
type PostgresConfig struct { Host string `json:"host" yaml:"host"` Port int `json:"port" yaml:"port"` Database string `json:"database" yaml:"database"` Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` SSLMode string `json:"ssl_mode" yaml:"ssl_mode"` }
PostgresConfig contains Postgres-specific configuration
type PostgresStorage ¶
type PostgresStorage struct {
// contains filtered or unexported fields
}
PostgresStorage implements ConversationStorage using PostgreSQL
func NewPostgresStorage ¶
func NewPostgresStorage(config PostgresConfig) (*PostgresStorage, error)
NewPostgresStorage creates a new PostgreSQL storage instance
func (*PostgresStorage) Close ¶
func (s *PostgresStorage) Close() error
Close closes the database connection
func (*PostgresStorage) DeleteConversation ¶
func (s *PostgresStorage) DeleteConversation(ctx context.Context, conversationID string) error
DeleteConversation removes a conversation by its ID
func (*PostgresStorage) Health ¶
func (s *PostgresStorage) Health(ctx context.Context) error
Health checks if the database is reachable and functional
func (*PostgresStorage) ListConversations ¶
func (s *PostgresStorage) ListConversations(ctx context.Context, limit, offset int) ([]ConversationSummary, error)
ListConversations returns a list of conversation summaries
func (*PostgresStorage) LoadConversation ¶
func (s *PostgresStorage) LoadConversation(ctx context.Context, conversationID string) ([]domain.ConversationEntry, ConversationMetadata, error)
LoadConversation loads a conversation by its ID
func (*PostgresStorage) SaveConversation ¶
func (s *PostgresStorage) SaveConversation(ctx context.Context, conversationID string, entries []domain.ConversationEntry, metadata ConversationMetadata) error
SaveConversation saves a conversation with its entries
func (*PostgresStorage) UpdateConversationMetadata ¶
func (s *PostgresStorage) UpdateConversationMetadata(ctx context.Context, conversationID string, metadata ConversationMetadata) error
UpdateConversationMetadata updates metadata for a conversation
type RedisConfig ¶
type RedisConfig struct { Host string `json:"host" yaml:"host"` Port int `json:"port" yaml:"port"` Database int `json:"database" yaml:"database"` Password string `json:"password,omitempty" yaml:"password,omitempty"` Username string `json:"username,omitempty" yaml:"username,omitempty"` TTL int `json:"ttl,omitempty" yaml:"ttl,omitempty"` // TTL in seconds, 0 means no expiration }
RedisConfig contains Redis-specific configuration
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
RedisStorage implements ConversationStorage using Redis
func NewRedisStorage ¶
func NewRedisStorage(config RedisConfig) (*RedisStorage, error)
NewRedisStorage creates a new Redis storage instance
func (*RedisStorage) DeleteConversation ¶
func (s *RedisStorage) DeleteConversation(ctx context.Context, conversationID string) error
DeleteConversation removes a conversation by its ID
func (*RedisStorage) Health ¶
func (s *RedisStorage) Health(ctx context.Context) error
Health checks if Redis is reachable and functional
func (*RedisStorage) ListConversations ¶
func (s *RedisStorage) ListConversations(ctx context.Context, limit, offset int) ([]ConversationSummary, error)
ListConversations returns a list of conversation summaries
func (*RedisStorage) LoadConversation ¶
func (s *RedisStorage) LoadConversation(ctx context.Context, conversationID string) ([]domain.ConversationEntry, ConversationMetadata, error)
LoadConversation loads a conversation by its ID
func (*RedisStorage) SaveConversation ¶
func (s *RedisStorage) SaveConversation(ctx context.Context, conversationID string, entries []domain.ConversationEntry, metadata ConversationMetadata) error
SaveConversation saves a conversation with its entries
func (*RedisStorage) UpdateConversationMetadata ¶
func (s *RedisStorage) UpdateConversationMetadata(ctx context.Context, conversationID string, metadata ConversationMetadata) error
UpdateConversationMetadata updates metadata for a conversation
type SQLiteConfig ¶
type SQLiteConfig struct {
Path string `json:"path" yaml:"path"`
}
SQLiteConfig contains SQLite-specific configuration
type SQLiteStorage ¶
type SQLiteStorage struct {
// contains filtered or unexported fields
}
SQLiteStorage implements ConversationStorage using SQLite
func NewSQLiteStorage ¶
func NewSQLiteStorage(config SQLiteConfig) (*SQLiteStorage, error)
NewSQLiteStorage creates a new SQLite storage instance
func (*SQLiteStorage) Close ¶
func (s *SQLiteStorage) Close() error
Close closes the database connection
func (*SQLiteStorage) DeleteConversation ¶
func (s *SQLiteStorage) DeleteConversation(ctx context.Context, conversationID string) error
DeleteConversation removes a conversation by its ID
func (*SQLiteStorage) Health ¶
func (s *SQLiteStorage) Health(ctx context.Context) error
Health checks if the database is reachable and functional
func (*SQLiteStorage) ListConversations ¶
func (s *SQLiteStorage) ListConversations(ctx context.Context, limit, offset int) ([]ConversationSummary, error)
ListConversations returns a list of conversation summaries
func (*SQLiteStorage) LoadConversation ¶
func (s *SQLiteStorage) LoadConversation(ctx context.Context, conversationID string) ([]domain.ConversationEntry, ConversationMetadata, error)
LoadConversation loads a conversation by its ID
func (*SQLiteStorage) SaveConversation ¶
func (s *SQLiteStorage) SaveConversation(ctx context.Context, conversationID string, entries []domain.ConversationEntry, metadata ConversationMetadata) error
SaveConversation saves a conversation with its entries
func (*SQLiteStorage) UpdateConversationMetadata ¶
func (s *SQLiteStorage) UpdateConversationMetadata(ctx context.Context, conversationID string, metadata ConversationMetadata) error
UpdateConversationMetadata updates metadata for a conversation
type StorageConfig ¶
type StorageConfig struct { // Type specifies the storage backend type (sqlite, postgres, redis) Type string `json:"type" yaml:"type"` // SQLite specific configuration SQLite SQLiteConfig `json:"sqlite,omitempty" yaml:"sqlite,omitempty"` // Postgres specific configuration Postgres PostgresConfig `json:"postgres,omitempty" yaml:"postgres,omitempty"` // Redis specific configuration Redis RedisConfig `json:"redis,omitempty" yaml:"redis,omitempty"` }
StorageConfig contains configuration for storage backends