Documentation
¶
Index ¶
- func IsBusyError(err error) bool
- func IsCorruptionError(err error) bool
- func IsNotFoundError(err error) bool
- func MigrateFromJSON(ctx context.Context, database *db.DB, dataDir string) error
- func RecoverFromCorruption(dataDir string) error
- type KVStore
- func (s *KVStore) Delete(ctx context.Context, key string) error
- func (s *KVStore) Get(ctx context.Context, key string, dest any) error
- func (s *KVStore) GetRaw(ctx context.Context, key string) (kv.Entry, error)
- func (s *KVStore) Has(ctx context.Context, key string) (bool, error)
- func (s *KVStore) ListKeys(ctx context.Context) ([]string, error)
- func (s *KVStore) Set(ctx context.Context, key string, value any) error
- func (s *KVStore) SetTTL(ctx context.Context, key string, value any, ttl time.Duration) error
- func (s *KVStore) SweepExpired(ctx context.Context) error
- type MessageStore
- func (m *MessageStore) Acknowledge(ctx context.Context, consumerID string, messageIDs []string) error
- func (m *MessageStore) GetUnread(ctx context.Context, consumerID string, topic string) ([]messaging.Message, error)
- func (m *MessageStore) List(ctx context.Context) ([]string, error)
- func (m *MessageStore) Prune(ctx context.Context, olderThan time.Duration) (int, error)
- func (m *MessageStore) Publish(ctx context.Context, msg messaging.Message, topics []string) error
- func (m *MessageStore) Subscribe(ctx context.Context, topic string, since time.Time) ([]messaging.Message, error)
- type NotifyStore
- type ReviewStore
- func (s *ReviewStore) CleanupStaleSessions(ctx context.Context, documentPath string, currentHash string) error
- func (s *ReviewStore) CreateSession(ctx context.Context, documentPath string, contentHash string) (review.Session, error)
- func (s *ReviewStore) DeleteComment(ctx context.Context, commentID string) error
- func (s *ReviewStore) DeleteSession(ctx context.Context, sessionID string) error
- func (s *ReviewStore) FinalizeSession(ctx context.Context, sessionID string) error
- func (s *ReviewStore) GetAllActiveSessionsWithCounts(ctx context.Context) (map[string]SessionInfo, error)
- func (s *ReviewStore) GetSession(ctx context.Context, documentPath string) (review.Session, error)
- func (s *ReviewStore) GetSessionByHash(ctx context.Context, documentPath string, contentHash string) (review.Session, error)
- func (s *ReviewStore) ListComments(ctx context.Context, sessionID string) ([]review.Comment, error)
- func (s *ReviewStore) SaveComment(ctx context.Context, comment review.Comment) error
- func (s *ReviewStore) UpdateComment(ctx context.Context, comment review.Comment) error
- type SessionFile
- type SessionInfo
- type SessionStore
- func (s *SessionStore) Delete(ctx context.Context, id string) error
- func (s *SessionStore) FindRecyclable(ctx context.Context, remote string) (session.Session, error)
- func (s *SessionStore) Get(ctx context.Context, id string) (session.Session, error)
- func (s *SessionStore) List(ctx context.Context) ([]session.Session, error)
- func (s *SessionStore) Save(ctx context.Context, sess session.Session) error
- type TopicFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBusyError ¶
IsBusyError returns true if the error is a SQLITE_BUSY error.
func IsCorruptionError ¶
IsCorruptionError returns true if the error indicates database corruption.
func IsNotFoundError ¶
IsNotFoundError returns true if the error is a "not found" error.
func MigrateFromJSON ¶
MigrateFromJSON migrates data from JSON files to SQLite if conditions are met: - sessions.json exists - Database has no sessions Skips migration if DB already populated to avoid duplicates.
func RecoverFromCorruption ¶
RecoverFromCorruption attempts to recover from database corruption by backing up the corrupted file and creating a new database.
Types ¶
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore implements kv.KV using SQLite.
func NewKVStore ¶
NewKVStore creates a new SQLite-backed KV store.
func (*KVStore) Get ¶
Get retrieves and deserializes a value by key. Returns an error wrapping sql.ErrNoRows if the key does not exist. Expired entries are lazily deleted and treated as missing.
func (*KVStore) GetRaw ¶
GetRaw retrieves a raw KV entry with metadata. Returns an error wrapping sql.ErrNoRows if the key does not exist.
type MessageStore ¶
type MessageStore struct {
// contains filtered or unexported fields
}
MessageStore implements messaging.Store using SQLite.
func NewMessageStore ¶
func NewMessageStore(db *db.DB, maxMessages int) *MessageStore
NewMessageStore creates a new SQLite-backed message store. maxMessages controls retention per topic (0 = unlimited).
func (*MessageStore) Acknowledge ¶
func (m *MessageStore) Acknowledge(ctx context.Context, consumerID string, messageIDs []string) error
Acknowledge marks messages as read by a consumer.
func (*MessageStore) GetUnread ¶
func (m *MessageStore) GetUnread(ctx context.Context, consumerID string, topic string) ([]messaging.Message, error)
GetUnread returns messages not yet acknowledged by consumer. Supports wildcard topic patterns.
func (*MessageStore) List ¶
func (m *MessageStore) List(ctx context.Context) ([]string, error)
List returns all topic names.
func (*MessageStore) Prune ¶
Prune removes messages older than the given duration across all topics. Returns the number of messages removed.
func (*MessageStore) Publish ¶
Publish adds a message to multiple topics. Wildcards are expanded before publishing. Enforces retention limit by deleting oldest messages if needed. All topics are published atomically within a single transaction.
func (*MessageStore) Subscribe ¶
func (m *MessageStore) Subscribe(ctx context.Context, topic string, since time.Time) ([]messaging.Message, error)
Subscribe returns all messages for a topic pattern, optionally filtered by since timestamp. The topic parameter supports wildcards:
- "*" or "" returns messages from all topics
- "prefix.*" matches topics starting with "prefix."
Returns ErrTopicNotFound if no matching topics exist.
type NotifyStore ¶
type NotifyStore struct {
// contains filtered or unexported fields
}
NotifyStore implements notify.Store using SQLite.
func NewNotifyStore ¶
func NewNotifyStore(db *db.DB) *NotifyStore
NewNotifyStore creates a new SQLite-backed notification store.
func (*NotifyStore) Clear ¶
func (s *NotifyStore) Clear(ctx context.Context) error
Clear deletes all notifications.
func (*NotifyStore) Count ¶
func (s *NotifyStore) Count(ctx context.Context) (int64, error)
Count returns the total number of notifications.
func (*NotifyStore) List ¶
func (s *NotifyStore) List(ctx context.Context) ([]notify.Notification, error)
List returns all notifications ordered by newest first.
func (*NotifyStore) Save ¶
func (s *NotifyStore) Save(ctx context.Context, n notify.Notification) (int64, error)
Save persists a notification and returns its auto-generated ID.
type ReviewStore ¶
type ReviewStore struct {
// contains filtered or unexported fields
}
ReviewStore implements review.Store using SQLite.
func NewReviewStore ¶
func NewReviewStore(db *db.DB) *ReviewStore
NewReviewStore creates a new SQLite-backed review store.
func (*ReviewStore) CleanupStaleSessions ¶
func (s *ReviewStore) CleanupStaleSessions(ctx context.Context, documentPath string, currentHash string) error
CleanupStaleSessions removes review sessions for a document with different content hash.
func (*ReviewStore) CreateSession ¶
func (s *ReviewStore) CreateSession(ctx context.Context, documentPath string, contentHash string) (review.Session, error)
CreateSession creates a new review session for a document with content hash.
func (*ReviewStore) DeleteComment ¶
func (s *ReviewStore) DeleteComment(ctx context.Context, commentID string) error
DeleteComment removes a specific comment.
func (*ReviewStore) DeleteSession ¶
func (s *ReviewStore) DeleteSession(ctx context.Context, sessionID string) error
DeleteSession removes a review session and all associated comments.
func (*ReviewStore) FinalizeSession ¶
func (s *ReviewStore) FinalizeSession(ctx context.Context, sessionID string) error
FinalizeSession marks a review session as finalized.
func (*ReviewStore) GetAllActiveSessionsWithCounts ¶
func (s *ReviewStore) GetAllActiveSessionsWithCounts(ctx context.Context) (map[string]SessionInfo, error)
GetAllActiveSessionsWithCounts returns all active (non-finalized) sessions with comment counts. This is optimized for batch operations like the document picker.
func (*ReviewStore) GetSession ¶
GetSession returns the most recent review session for the given document.
func (*ReviewStore) GetSessionByHash ¶
func (s *ReviewStore) GetSessionByHash(ctx context.Context, documentPath string, contentHash string) (review.Session, error)
GetSessionByHash returns a review session for the given document and content hash.
func (*ReviewStore) ListComments ¶
ListComments returns all comments for a review session, sorted by start line.
func (*ReviewStore) SaveComment ¶
SaveComment adds a comment to a review session.
func (*ReviewStore) UpdateComment ¶
UpdateComment updates the comment text for an existing comment.
type SessionFile ¶
SessionFile is the root JSON structure for sessions.json
type SessionInfo ¶
SessionInfo contains session data with comment count for efficient batch queries.
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore implements session.Store using SQLite.
func NewSessionStore ¶
func NewSessionStore(db *db.DB) *SessionStore
NewSessionStore creates a new SQLite-backed session store.
func (*SessionStore) Delete ¶
func (s *SessionStore) Delete(ctx context.Context, id string) error
Delete removes a session by ID. Returns ErrNotFound if not found.
func (*SessionStore) FindRecyclable ¶
FindRecyclable returns a recyclable session for the given remote. Returns ErrNoRecyclable if none available.