feat(session): add Close to SessionStore interface

Add Close() error to SessionStore so callers can release resources
through the interface. JSONLBackend already had Close; this adds
a no-op implementation to SessionManager for compatibility.
This commit is contained in:
xiaoen 2026-03-07 21:17:14 +08:00
parent 1434edcb76
commit 848f452648
2 changed files with 7 additions and 0 deletions

View file

@ -265,6 +265,12 @@ func (sm *SessionManager) loadSessions() error {
return nil return nil
} }
// Close is a no-op for the in-memory SessionManager; it satisfies the
// SessionStore interface so callers can release resources uniformly.
func (sm *SessionManager) Close() error {
return nil
}
// SetHistory updates the messages of a session. // SetHistory updates the messages of a session.
func (sm *SessionManager) SetHistory(key string, history []providers.Message) { func (sm *SessionManager) SetHistory(key string, history []providers.Message) {
sm.mu.Lock() sm.mu.Lock()

View file

@ -15,4 +15,5 @@ type SessionStore interface {
SetHistory(key string, history []providers.Message) SetHistory(key string, history []providers.Message)
TruncateHistory(key string, keepLast int) TruncateHistory(key string, keepLast int)
Save(key string) error Save(key string) error
Close() error
} }