Documentation ¶
Overview ¶
Package pbcmpl provides a header for proto.Message
One of the known protobuf issue is that user must control the size when unmarshaling. This package gives a solution to add a header for every proto.Message, in which there are: a semantic-version for checking compatibility, a header size and size of marshaled proto.Message.
Since 0.1.6
Index ¶
Constants ¶
const ( // DefaultVer is the default version if the message to marshal does not // provide version. // // Since v0.1.6 DefaultVer = "1.0.0" )
Variables ¶
var ( // ErrInvalidHeaderSize indicates the size in the header is incorrect ErrInvalidHeaderSize = errors.New("headersize is incorrect") )
Functions ¶
func HeaderSize ¶
HeaderSize returns the marshaled size of the header for a proto.Message .
Since 0.1.6
func Marshal ¶
Marshal a proto.Message following a small header into an io.Writer. The header contains version(if msg is a VersionedMessage), header size and payload size.
It returns the number of written bytes and an error.
Since v0.1.6
Types ¶
type Header ¶ added in v0.1.7
Header defines header info retrieving APIs.
Since 0.1.7
func ReadHeader ¶ added in v0.1.7
ReadHeader reads header info from a stream marshaled by this module. It returns number of bytes it has read, a Header interface for retreiving header info and an error. The number of bytes may be greater than 0 even if there is an error.
Since 0.1.7
type VersionedMessage ¶
VersionedMessage must provide a "GetVersion" returning the version of a proto.Message . The version is a string in 16 bytes.
Since 0.1.6