I have a case where I would like to reuse a TProtocol instance after a
write/flush error occurs on the protocol.

For example, imagine I have a transport which has a size limit on message
frames, and it returns an error if you exceed that limit. The error is
bubbled up to the user, who is then responsible for making a smaller
request. The problem is that some TProtocols have state associated with
them (e.g. in Go, TJSONProtocol has a write buffer and a parse context), so
after an error they are in an invalid state and subsequent uses of them
produce corrupted data. TBinaryProtocol doesn't seem to have this issue.

My question is: would it be reasonable to expose a method for "resetting" a
TProtocol back to its original state such that it can be safely reused
after a failed write or flush?

Thanks,

Reply via email to