Documentation ¶
Index ¶
- type DataFactory
- type DataFactoryRegistry
- type EncoderDecoder
- func (ed *EncoderDecoder) DecodeData(messageType string, version *semver.Version, data interface{}) (interface{}, error)
- func (ed *EncoderDecoder) DecodeMessageType(schema string) (string, *semver.Version, error)
- func (ed *EncoderDecoder) EncodeData(data interface{}, useMessageTransport bool, metaAttrs hedwig.MetaAttributes) ([]byte, error)
- func (ed *EncoderDecoder) EncodeMessageType(messageType string, version *semver.Version) string
- func (ed *EncoderDecoder) ExtractData(messagePayload []byte, attributes map[string]string) (hedwig.MetaAttributes, interface{}, error)
- func (ed *EncoderDecoder) VerifyKnownMinorVersion(messageType string, version *semver.Version) error
- type JSONTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataFactory ¶ added in v0.8.0
type DataFactory func() interface{}
DataFactory is a function that returns a pointer to struct type that a hedwig message data should conform to
type DataFactoryRegistry ¶ added in v0.8.0
type DataFactoryRegistry map[hedwig.MessageTypeMajorVersion]DataFactory
DataFactoryRegistry is the map of message type and major versions to a factory function
type EncoderDecoder ¶ added in v0.8.0
type EncoderDecoder struct {
// contains filtered or unexported fields
}
EncoderDecoder is an implementation of hedwig.Encoder and hedwig.Decoder that uses JSON Schema
func NewEncoderDecoderFromBytes ¶ added in v0.8.0
func NewEncoderDecoderFromBytes(schemaFile []byte, dataRegistry DataFactoryRegistry) (*EncoderDecoder, error)
NewEncoderDecoderFromBytes creates an encoder / decoder from a byte encoded JSON schema file
func NewMessageEncoderDecoder ¶ added in v0.8.0
func NewMessageEncoderDecoder(schemaFilePath string, dataRegistry DataFactoryRegistry) (*EncoderDecoder, error)
NewMessageEncoderDecoder creates a new encoder from the given file
func (*EncoderDecoder) DecodeData ¶ added in v0.8.0
func (ed *EncoderDecoder) DecodeData(messageType string, version *semver.Version, data interface{}) (interface{}, error)
DecodeData validates and decodes data
func (*EncoderDecoder) DecodeMessageType ¶ added in v0.8.0
DecodeMessageType decodes message type from meta attributes
func (*EncoderDecoder) EncodeData ¶ added in v0.8.0
func (ed *EncoderDecoder) EncodeData(data interface{}, useMessageTransport bool, metaAttrs hedwig.MetaAttributes) ([]byte, error)
EncodeData encodes the message with appropriate format for transport over the wire
func (*EncoderDecoder) EncodeMessageType ¶ added in v0.8.0
func (ed *EncoderDecoder) EncodeMessageType(messageType string, version *semver.Version) string
EncodeMessageType encodes the message type with appropriate format for transport over the wire
func (*EncoderDecoder) ExtractData ¶ added in v0.8.0
func (ed *EncoderDecoder) ExtractData(messagePayload []byte, attributes map[string]string) (hedwig.MetaAttributes, interface{}, error)
ExtractData extracts data from the on-the-wire payload when not using message transport
func (*EncoderDecoder) VerifyKnownMinorVersion ¶ added in v0.8.0
func (ed *EncoderDecoder) VerifyKnownMinorVersion(messageType string, version *semver.Version) error
VerifyKnownMinorVersion checks that message version is known to us
type JSONTime ¶
JSONTime is just a wrapper around time that serializes time to epoch in milliseconds
func (JSONTime) MarshalJSON ¶
MarshalJSON changes time to epoch in milliseconds
func (*JSONTime) UnmarshalJSON ¶
UnmarshalJSON changes time from epoch in milliseconds