parse event from the binance private stream

This commit is contained in:
c9s 2020-06-29 03:11:05 +08:00
parent 338d2443b9
commit 4cd96360b3

View File

@ -82,8 +82,8 @@ func (s *PrivateStream) Connect(ctx context.Context) error {
return nil return nil
} }
func (s *PrivateStream) Read(ctx context.Context, messages chan []byte) { func (s *PrivateStream) Read(ctx context.Context, eventC chan interface{}) {
defer close(messages) defer close(eventC)
ticker := time.NewTicker(1 * time.Minute) ticker := time.NewTicker(1 * time.Minute)
defer ticker.Stop() defer ticker.Stop()
@ -112,7 +112,14 @@ func (s *PrivateStream) Read(ctx context.Context, messages chan []byte) {
} }
log.Debugf("[binance] recv: %s", message) log.Debugf("[binance] recv: %s", message)
messages <- message
e, err := ParseBinanceEvent(string(message))
if err != nil {
log.WithError(err).Errorf("[binance] event parse error")
continue
}
eventC <- e
} }
} }
} }