talostrading / sonic

Sonic is a Go library for network and I/O programming that provides developers with a consistent asynchronous model, with a focus on achieving the lowest possible latency and jitter in Go.
MIT License
676 stars 16 forks source link

Zero-copy reading for websocket #100

Open sergiu128 opened 1 year ago

sergiu128 commented 1 year ago

Right now we have AsyncNextMessage(b []byte, ...). Inside this we memcpy the message into the user supplied buffer. We need to offer an alternative that just returns the websocket's buffer in a callback. For messages composed of multiple frames, we can return a list of buffers, one for each frame.