francoispqt / gojay

high performance JSON encoder/decoder with stream API for Golang
MIT License
2.11k stars 113 forks source link

Stream encoding with gojay seems to be a problem. #169

Open shawlleyw opened 2 years ago

shawlleyw commented 2 years ago

I was just running the stream encoding example given in README and got into trouble.

  1. Stream encoding API supports enc.Done() to synchronize consumers and help them exit after all jobs are done. However it does not support any ways to notify consumers that no more jobs would be delivered in future. Unfortunately this would trap all consumers into endless wait, or deadlock.

fatal error: all goroutines are asleep - deadlock!

  1. The order of output stream is not consistent with input stream while mulitiple consumers are working together.

By the way, the example given in README has a trivial bug, enc.Object(o) should not be called there, it should be enc.AddObject(o) instead.

shawlleyw commented 2 years ago

Considering this repo might be orphaned and would be maintained no more, I would like to link another high performance json tool with streaming API here. Hope it would help someone.

https://github.com/bytedance/sonic