• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stacklok / toolhive / 18463697957

13 Oct 2025 11:04AM UTC coverage: 46.58% (+0.4%) from 46.187%
18463697957

push

github

web-flow
feat: Add pluggable storage backend for session management (#1989)

* feat: Add pluggable storage backend for session management

Refactors the session management system to use a pluggable storage
interface, enabling future support for distributed storage backends
like Redis/Valkey while maintaining backward compatibility.

What Changed

- Introduced a Storage interface that abstracts session persistence
- Refactored Manager to use the Storage interface instead of directly
  using sync.Map
- Created LocalStorage implementation that maintains the existing
  in-memory behavior
- Added JSON serialization support for sessions to enable future
  network storage
- Extended Session interface with Type() and metadata methods that
  were already implemented in concrete types

Why

The previous implementation was tightly coupled to in-memory storage,
making it impossible to share sessions across multiple ToolHive instances.
This refactoring enables:
- Horizontal scaling with shared session state
- Session persistence across restarts
- Future Redis/Valkey backend support without breaking changes

Testing

Added comprehensive unit tests covering:
- LocalStorage implementation
- Session serialization/deserialization
- Manager with pluggable storage
- All existing session types (ProxySession, SSESession, StreamableSession)

All tests pass and the implementation maintains full backward compatibility.

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>

* Address PR feedback: fix race condition and encapsulation issues

- Fix race condition in LocalStorage.Close() by collecting keys before deletion
- Update Close() comment to reflect actual behavior (clears sessions, not a no-op)
- Add setter methods (setTimestamps, setMetadataMap) to ProxySession for proper encapsulation
- Update serialization to use setter methods instead of direct field access
- Fix StreamableSession constructor to use NewTypedProxySession for proper initialization
- Add type assertion check in... (continued)

197 of 220 new or added lines in 7 files covered. (89.55%)

29 existing lines in 4 files now uncovered.

17414 of 37385 relevant lines covered (46.58%)

16.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.17
/pkg/transport/proxy/httpsse/http_proxy.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc