Documentation ¶
Index ¶
Constants ¶
const IdLength = 64
IdLength is the length of a data payload id.
const MaxDataPayloadSize = 64 * 1024
MaxDataPayloadSize defines the maximum size of a data payload.
const (
// ObjectName defines the name of the data object.
ObjectName = "data"
)
Variables ¶
var DataType = Type(0)
DataType is the message type of a data payload.
var ( // ErrMaximumPayloadSizeExceeded is returned if the payload exceeds the maximum size. ErrMaximumPayloadSizeExceeded = errors.New("maximum payload size exceeded") )
Functions ¶
func RegisterType ¶
func RegisterType(payloadType Type, payloadName string, unmarshaler Unmarshaler)
RegisterType registers a payload type with the given unmarshaler.
func SetGenericUnmarshalerFactory ¶
func SetGenericUnmarshalerFactory(unmarshalerFactory func(payloadType Type) Unmarshaler)
SetGenericUnmarshalerFactory sets the generic unmarshaler.
Types ¶
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data represents a payload which just contains a blob of data.
func DataFromBytes ¶
func DataFromBytes(bytes []byte, optionalTargetObject ...*Data) (result *Data, err error, consumedBytes int)
DataFromBytes creates a new data payload from the given bytes.
func ParseData ¶
func ParseData(marshalUtil *marshalutil.MarshalUtil, optionalTargetObject ...*Data) (result *Data, err error)
ParseData parses a new data payload out of the given marshal util.
type Definition ¶
type Definition struct { Name string Unmarshaler }
Definition defines the properties of a payload type.
type Id ¶
ID represents the id of a data payload.
type Payload ¶
type Payload interface { // Type returns the type of the payload. Type() Type // Bytes returns the payload bytes. Bytes() []byte // Unmarshal unmarshals the payload from the given bytes. Unmarshal(bytes []byte) error // String returns a human-friendly representation of the payload. String() string }
Payload represents some kind of payload of data which only gains meaning by having corresponding node logic processing payloads of a given type.
func Parse ¶
func Parse(marshalUtil *marshalutil.MarshalUtil) (Payload, error)
Parse parses a payload by using the given marshal util.
type Unmarshaler ¶
Unmarshaler takes some data and unmarshals it into a payload.
func GenericPayloadUnmarshalerFactory ¶
func GenericPayloadUnmarshalerFactory(payloadType Type) Unmarshaler
GenericPayloadUnmarshalerFactory is an unmarshaler for the generic data payload type.
func GetUnmarshaler ¶
func GetUnmarshaler(payloadType Type) Unmarshaler
GetUnmarshaler returns the unmarshaler for the given type if known or the generic unmarshaler if the given payload type has no associated unmarshaler.