1.9 KiB
1.9 KiB
Implement Missing Roadmap Features (Phase 2)
I will implement the key missing features from Phase 2 of the roadmap to improve compatibility with the Supabase client SDK.
1. Realtime Presence (realtime crate)
Goal: Enable user state tracking (online/offline, custom status) compatible with supabase-js.
- Dependencies: Add
dashmapfor thread-safe concurrent state management. - State Management: Update
RealtimeStateto store presence data in memory:Arc<DashMap<Topic, DashMap<ClientID, PresenceData>>>. - WebSocket Logic:
- Handle
presenceevents (join, leave, sync). - Implement
track(user joins/updates state) anduntrack(user leaves). - Broadcast
presence_diffevents to all subscribers on a topic when state changes.
- Handle
2. Storage Image Transformations (storage crate)
Goal: Support on-the-fly image resizing and formatting via query parameters.
- Dependencies: Add
imagecrate (withjpeg,png,webpsupport). - Handler Update: Modify
download_objectto parse query parameters:w/width: Target width.h/height: Target height.q/quality: Compression quality.f/format: Output format (e.g.,webp,png).
- Processing Logic:
- If parameters are present, decode the downloaded image bytes.
- Apply resizing (using
Lanczos3filter for quality). - Encode to the target format/quality.
- Return the processed image with correct
Content-Type.
Execution Steps
- Update Dependencies: Add
dashmaptorealtime/Cargo.tomlandimagetostorage/Cargo.toml. - Refactor Realtime: Modify
RealtimeStateandws.rsto implement the Presence protocol. - Refactor Storage: Modify
handlers.rsto implement the Image Transformation pipeline. - Verification: Verify compilation and basic functionality (via
cargo checkand manual review of the logic).