mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
maxapi: use fastjson parser pool
This commit is contained in:
parent
2bd93b4d25
commit
905148a34f
|
@ -16,10 +16,13 @@ var ErrIncorrectBookEntryElementLength = errors.New("incorrect book entry elemen
|
|||
const Buy = 1
|
||||
const Sell = -1
|
||||
|
||||
var parserPool fastjson.ParserPool
|
||||
|
||||
// ParseMessage accepts the raw messages from max public websocket channels and parses them into market data
|
||||
// Return types: *BookEvent, *PublicTradeEvent, *SubscriptionEvent, *ErrorEvent
|
||||
func ParseMessage(payload []byte) (interface{}, error) {
|
||||
parser := fastjson.Parser{}
|
||||
parser := parserPool.Get()
|
||||
|
||||
val, err := parser.ParseBytes(payload)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to parse payload: "+string(payload))
|
||||
|
|
Loading…
Reference in New Issue
Block a user