Skip to content

Commit

Permalink
fix order watchChange routine
Browse files Browse the repository at this point in the history
  • Loading branch information
nghiatomo committed Apr 29, 2020
1 parent 11dd0c8 commit 9130a14
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions services/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,17 @@ func (s *OrderService) broadcastRawOrderBookUpdate(orders []*types.Order) {
ws.GetRawOrderBookSocket().BroadcastMessage(id, orders)
}

// WatchChanges wath change record
func (s *OrderService) WatchChanges() {
go func() {
for {
<-time.After(500 * time.Millisecond)
s.processBulkOrders()
}
}()
s.watchChanges()
}
func (s *OrderService) watchChanges() {
ct, sc, err := s.orderDao.Watch()

if err != nil {
Expand All @@ -545,12 +555,6 @@ func (s *OrderService) WatchChanges() {
defer s.WatchChanges()

ctx := context.Background()
go func() {
for {
<-time.After(500 * time.Millisecond)
s.processBulkOrders()
}
}()

//Handling change stream in a cycle
for {
Expand Down

0 comments on commit 9130a14

Please sign in to comment.