marshaller

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnregisteredType  = errors.New("unregistered type")
	ErrInstantiatingType = errors.New("cannot instantiate type")
	ErrAlreadyRegistered = errors.New("type already registered")
	ErrInvalidDataType   = errors.New("invalid data type")
)
View Source
var ErrEmptyUnmarshallerChain = errors.New("empty unmarshaller chain")
View Source
var ErrUnmarshalling = errors.New("failed to unmarshall")

Functions

This section is empty.

Types

type ByteMarshaller

type ByteMarshaller struct{}

ByteMarshaller accepts payloads as string or byte slice and returns it as is.

func (*ByteMarshaller) Marshal

func (m *ByteMarshaller) Marshal(data interface{}) ([]byte, string, error)

Marshal marshalls a string or byte slice payloads.

func (*ByteMarshaller) Unmarshal

func (m *ByteMarshaller) Unmarshal(_ string, message pubsub.ReceivedMessage) (interface{}, error)

Unmarshal unmarshals a string or byte slice.

type ChainUnmarshaller added in v0.3.2

type ChainUnmarshaller struct {
	// contains filtered or unexported fields
}

func NewChainUnmarshaller added in v0.3.2

func NewChainUnmarshaller(unmarshallers ...pubsub.Unmarshaller) *ChainUnmarshaller

func (*ChainUnmarshaller) Unmarshal added in v0.3.2

func (c *ChainUnmarshaller) Unmarshal(topic string, message pubsub.ReceivedMessage) (interface{}, error)

type JSONMarshaller

type JSONMarshaller struct {
	// contains filtered or unexported fields
}

JSONMarshaller uses the standards json library to encode and decode message.

func (*JSONMarshaller) Marshal

func (m *JSONMarshaller) Marshal(v interface{}) ([]byte, string, error)

Marshal marshals the message data as JSON.

func (*JSONMarshaller) Register

func (m *JSONMarshaller) Register(key string, v interface{}) error

Register an event type by event name or topic.

func (*JSONMarshaller) Unmarshal

func (m *JSONMarshaller) Unmarshal(topic string, message pubsub.ReceivedMessage) (interface{}, error)

Unmarshal unmarshall the message body as JSON.

type TypeRegistry added in v0.3.2

type TypeRegistry struct {
	// contains filtered or unexported fields
}

func (*TypeRegistry) GetNew added in v0.3.2

func (r *TypeRegistry) GetNew(topic, name string) (interface{}, error)

func (*TypeRegistry) GetType added in v0.3.2

func (r *TypeRegistry) GetType(topic, name string) (reflect.Type, error)

func (*TypeRegistry) Register added in v0.3.2

func (r *TypeRegistry) Register(key string, v interface{}) (err error)

Jump to

Keyboard shortcuts

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