How anephenix/sarus works
Main Components Identification
a. Core WebSocket Management Layer
• WebSocket Connection Handler
• Automatic Reconnection System
• Event Listener Manager
• Message Queue System
b. Storage Systems
• In-Memory Storage
• Browser Storage Integration (LocalStorage/SessionStorage)
c. Configuration Management
• Connection Options
• Exponential Backoff Handler
• Data Transformers
[Client Application] → [Sarus Library]
• ↓
• ┌─────────────────────────────────────────┐
• Sarus Core │
• ┌─────────────┐ ┌──────────────┐ │
• WebSocket │←────→│Event Listener│ │
• Manager │ │ Manager │ │
• ┘ └──────────────┘ │
• ↕ ↕ │
• ┌─────────────┐ ┌──────────────┐ │
• Message │←────→│ Storage │ │
• Queue │ │ Bridge │ │
• ┘ └──────────────┘ │
• ┘
• ↕
• ┌─────────────────────────────────────────┐
• Storage Implementations │
• ┌─────────────┐ ┌──────────────┐ │
• In-Memory │ │ Browser │ │
• Storage │ │ Storage │ │
• ┘ └──────────────┘ │
• ┘
• ↓
• [WebSocket Server Connection]
Component Details
For each major component, include:
a. WebSocket Manager:
• Connection state handling
• Reconnection logic with exponential backoff
• Protocol management
b. Event Listener Manager:
• Event binding/unbinding
• Event persistence across reconnections
• Event type handling (open, message, close, error)
c. Message Queue:
• Message persistence
• Retry logic
• Queue state management
d. Storage Bridge:
• Storage type selection (memory/session/local)
• Storage quota management
• Data serialization/deserialization
Important Notes
Specific callouts:
• Automatic reconnection flow
• Message queue persistence options
• Exponential backoff logic
• Event listener rebinding process
Implementation Details
Technical notes showing:
• TypeScript implementation
• Browser compatibility
• Storage quotas and limitations
• Protocol support
Integration Points
Clearly mark:
• Client application integration points
• WebSocket server connection details
• Storage system interfaces
• Event handling hooks
This design accurately represents Sarus's architecture while highlighting its robust handling of WebSocket connections, event management, and message queuing capabilities.