jsonschema

package
v0.11.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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

func (ed *EncoderDecoder) DecodeMessageType(schema string) (string, *semver.Version, error)

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) IsBinary added in v0.11.0

func (ed *EncoderDecoder) IsBinary() bool

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

type JSONTime time.Time

JSONTime is just a wrapper around time that serializes time to epoch in milliseconds

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON changes time to epoch in milliseconds

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(b []byte) error

UnmarshalJSON changes time from epoch in milliseconds

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL