fix: remove legacy RebalancingService and migrate WebSocket broadcast to AutoRebalancerService#23
Merged
Uchechukwu-Ekezie merged 32 commits intoJun 24, 2026
Conversation
…o AutoRebalancerService
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5
Problem
RebalancingService(monitoring/rebalancer.ts) was left instantiated and started inindex.tseven after it was superseded byAutoRebalancerService. Two problems remained:new RebalancingService(wss)+rebalancingService.start()ran on every server boot, did nothing (the cron had already been removed), and added noise.notifyClients()andbroadcastToAllClients()lived only insideRebalancingServiceand were never called, silently dropping real-time portfolio events.Changes
backend/src/index.ts— 1 line removed, 9 lines removed, 2 addedbackend/src/services/autoRebalancer.ts— 54 lines addedimport { WebSocketServer } from 'ws'private wss: WebSocketServer | null = nullfieldsetWss(wss)— called fromindex.tsafter the WebSocket server is createdhasWss()— useful for health checks and testsnotifyClients(portfolioId, event, data)fromRebalancingServicebroadcastToAllClients(event, data)fromRebalancingServicebackend/src/monitoring/rebalancer.ts— deletedAll live functionality has been consolidated into
AutoRebalancerService.Why
setWss()instead of constructor injectionautoRebalanceris instantiated at line 86 ofindex.tsbutwss = new WebSocketServer(...)is created at line 214.setWss()avoids reordering the startup sequence and keeps the change minimal.Failure scenarios resolved
recordRebalanceEvent()writesnotifyClients()now reachable