Skip to content

Commit

Permalink
fix: fix merge conflict error
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Aug 3, 2024
1 parent cb7a203 commit 9a3583b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions node/pkg/dal/api/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ func (h *Hub) removeClient(client *ThreadSafeClient) {
}
}

func (c *Hub) getClientsSnapshotToNotify(symbol string) []*ThreadSafeClient {
c.mu.RLock()
defer c.mu.RUnlock()
func (h *Hub) getClientsSnapshotToNotify(symbol string) []*ThreadSafeClient {
h.mu.RLock()
defer h.mu.RUnlock()
result := []*ThreadSafeClient{}
for client, subscriptions := range c.clients {
for client, subscriptions := range h.clients {
if subscriptions[symbol] {
result = append(result, client)
}
}
return result
}

func (c *Hub) initializeBroadcastChannels(collector *collector.Collector) {
func (h *Hub) initializeBroadcastChannels(collector *collector.Collector) {
for configId, stream := range collector.OutgoingStream {
symbol := h.configIdToSymbol(configId)
if symbol == "" {
Expand All @@ -165,17 +165,17 @@ func (h *Hub) broadcastDataForSymbol(symbol string) {
}

// pass by pointer to reduce memory copy time
func (c *Hub) castSubmissionData(data *dalcommon.OutgoingSubmissionData, symbol *string) {
func (h *Hub) castSubmissionData(data *dalcommon.OutgoingSubmissionData, symbol *string) {
var wg sync.WaitGroup
clientsToNotify := c.getClientsSnapshotToNotify(*symbol)
clientsToNotify := h.getClientsSnapshotToNotify(*symbol)

for _, client := range clientsToNotify {
wg.Add(1)
go func(entry *ThreadSafeClient) {
defer wg.Done()
if err := entry.WriteJSON(*data); err != nil {
log.Error().Err(err).Msg("failed to write message")
c.unregister <- entry
h.unregister <- entry
}
}(client)
}
Expand Down

0 comments on commit 9a3583b

Please sign in to comment.