Documentation ¶
Index ¶
- Variables
- type PayloadInitiator
- type PayloadTransformer
- func (p *PayloadTransformer) ConvertPayload(payload interface{}) (string, []byte, error)
- func (p *PayloadTransformer) CreatePayload(typeName string, data interface{}) (interface{}, error)
- func (p *PayloadTransformer) RegisterPayload(payloadType string, initiator PayloadInitiator) error
- func (p *PayloadTransformer) RegisterPayloads(payloads map[string]PayloadInitiator) error
- func (p *PayloadTransformer) ResolveName(payload interface{}) (string, error)
- type PayloadType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedJSONPayloadData occurs when the data type is not supported by the PayloadTransformer ErrUnsupportedJSONPayloadData = errors.New("goengine: payload data was expected to be a []byte, json.RawMessage or string") // ErrPayloadCannotBeSerialized occurs when the payload cannot be serialized ErrPayloadCannotBeSerialized = errors.New("goengine: payload cannot be serialized") // ErrPayloadNotRegistered occurs when the payload is not registered ErrPayloadNotRegistered = errors.New("goengine: payload is not registered") // ErrUnknownPayloadType occurs when a payload type is unknown ErrUnknownPayloadType = errors.New("goengine: unknown payload type provided") // ErrInitiatorInvalidResult occurs when a PayloadInitiator returns a reference to nil ErrInitiatorInvalidResult = errors.New("goengine: initializer must return a pointer that is not nil") // ErrDuplicatePayloadType occurs when a payload type is already registered ErrDuplicatePayloadType = errors.New("goengine: payload type is already registered") )
Functions ¶
This section is empty.
Types ¶
type PayloadInitiator ¶
type PayloadInitiator func() interface{}
PayloadInitiator creates a new empty instance of a Payload this instance can then be used to Unmarshal
type PayloadTransformer ¶
type PayloadTransformer struct {
// contains filtered or unexported fields
}
PayloadTransformer is a payload factory that can reconstruct payload from and to JSON
func NewPayloadTransformer ¶
func NewPayloadTransformer() *PayloadTransformer
NewPayloadTransformer returns a new instance of the PayloadTransformer
func (*PayloadTransformer) ConvertPayload ¶
func (p *PayloadTransformer) ConvertPayload(payload interface{}) (string, []byte, error)
ConvertPayload marshall the payload into JSON returning the payload fullpkgPath and the serialized data.
func (*PayloadTransformer) CreatePayload ¶
func (p *PayloadTransformer) CreatePayload(typeName string, data interface{}) (interface{}, error)
CreatePayload reconstructs a payload based on its type and the json data
func (*PayloadTransformer) RegisterPayload ¶
func (p *PayloadTransformer) RegisterPayload(payloadType string, initiator PayloadInitiator) error
RegisterPayload registers a payload type and the way to initialize it with the factory
func (*PayloadTransformer) RegisterPayloads ¶
func (p *PayloadTransformer) RegisterPayloads(payloads map[string]PayloadInitiator) error
RegisterPayloads registers multiple payload types
func (*PayloadTransformer) ResolveName ¶
func (p *PayloadTransformer) ResolveName(payload interface{}) (string, error)
ResolveName returns the payloadType name of the provided payload
type PayloadType ¶
type PayloadType struct {
// contains filtered or unexported fields
}
PayloadType represents a payload and the way to create it