jiffy icon indicating copy to clipboard operation
jiffy copied to clipboard

Add return_truncated decode flag

Open sargun opened this issue 6 years ago • 5 comments

sargun avatar Nov 22 '17 09:11 sargun

The use case is that I have a protocol which takes JSON over streaming sockets (TCP, websocket). JSON is basically the "framing" format. Because of the properties of the protocol, you can get partial frames. In that case, I know to go ahead and wait for more and add it to the buffer before trying to decode again.

I know that JSX has a streaming API, but I personally find it really difficult to use, especially when my messages are <16KB. A simple decode, append, continue loop works just fine.

sargun avatar Nov 22 '17 22:11 sargun

That makes sense but with the return_trailer and existing trucated exception I’m not seeing what the extra position is giving. Seems like it’d always be the end of the binary no?

On Wed, Nov 22, 2017 at 4:16 PM Sargun Dhillon [email protected] wrote:

The use case is that I have a protocol which takes JSON over streaming sockets (TCP, websocket). JSON is basically the "framing" format. Because of the properties of the protocol, you can get partial frames. In that case, I know to go ahead and wait for more and add it to the buffer before trying to decode again.

I know that JSX has a streaming API, but I personally find it really difficult to use, especially when my messages are <16KB. A simple decode, append, continue loop works just fine.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/davisp/jiffy/pull/158#issuecomment-346487711, or mute the thread https://github.com/notifications/unsubscribe-auth/AABN2Usdu-86vmbHTaKXkW2jrdWDMeCPks5s5J01gaJpZM4QnIKW .

davisp avatar Nov 22 '17 22:11 davisp

Yeah, I'd think so, the only reason I'm returning the extra position is because I wanted it to be as similar to the existing API mechanism as possible. I agree, it doesn't make a lot of sense, but I'd hate to break API backwards compatibility.

sargun avatar Nov 24 '17 21:11 sargun

Fixed the braces.

sargun avatar Nov 25 '17 22:11 sargun

How do you want to proceed?

sargun avatar Dec 04 '17 05:12 sargun