Documentation ¶
Index ¶
- Constants
- Variables
- type ByteSlicePayloadConverter
- func (c *ByteSlicePayloadConverter) Encoding() string
- func (c *ByteSlicePayloadConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
- func (c *ByteSlicePayloadConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
- func (c *ByteSlicePayloadConverter) ToString(payload *commonpb.Payload) string
- type CompositeDataConverter
- func (dc *CompositeDataConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
- func (dc *CompositeDataConverter) FromPayloads(payloads *commonpb.Payloads, valuePtrs ...interface{}) error
- func (dc *CompositeDataConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
- func (dc *CompositeDataConverter) ToPayloads(values ...interface{}) (*commonpb.Payloads, error)
- func (dc *CompositeDataConverter) ToString(payload *commonpb.Payload) string
- func (dc *CompositeDataConverter) ToStrings(payloads *commonpb.Payloads) []string
- type DataConverter
- type EncodedValue
- type EncodedValues
- type JSONPayloadConverter
- func (c *JSONPayloadConverter) Encoding() string
- func (c *JSONPayloadConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
- func (c *JSONPayloadConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
- func (c *JSONPayloadConverter) ToString(payload *commonpb.Payload) string
- type NilPayloadConverter
- type PayloadConverter
- type ProtoJSONPayloadConverter
- func (c *ProtoJSONPayloadConverter) Encoding() string
- func (c *ProtoJSONPayloadConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
- func (c *ProtoJSONPayloadConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
- func (c *ProtoJSONPayloadConverter) ToString(payload *commonpb.Payload) string
- type ProtoPayloadConverter
- func (c *ProtoPayloadConverter) Encoding() string
- func (c *ProtoPayloadConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
- func (c *ProtoPayloadConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
- func (c *ProtoPayloadConverter) ToString(payload *commonpb.Payload) string
Constants ¶
const ( // MetadataEncoding is "encoding" MetadataEncoding = "encoding" // MetadataEncodingBinary is "binary/plain" MetadataEncodingBinary = "binary/plain" // MetadataEncodingJSON is "json/plain" MetadataEncodingJSON = "json/plain" // MetadataEncodingNil is "binary/null" MetadataEncodingNil = "binary/null" // MetadataEncodingProtoJSON is "json/protobuf" MetadataEncodingProtoJSON = "json/protobuf" // MetadataEncodingProto is "binary/protobuf" MetadataEncodingProto = "binary/protobuf" )
Variables ¶
var ( // ErrMetadataIsNotSet is returned when metadata is not set. ErrMetadataIsNotSet = errors.New("metadata is not set") // ErrEncodingIsNotSet is returned when payload encoding metadata is not set. ErrEncodingIsNotSet = errors.New("payload encoding metadata is not set") // ErrEncodingIsNotSupported is returned when payload encoding is not supported. ErrEncodingIsNotSupported = errors.New("payload encoding is not supported") // ErrUnableToEncode is returned when unable to encode. ErrUnableToEncode = errors.New("unable to encode") // ErrUnableToDecode is returned when unable to decode. ErrUnableToDecode = errors.New("unable to decode") // ErrUnableToSetValue is returned when unable to set value. ErrUnableToSetValue = errors.New("unable to set value") // ErrUnableToFindConverter is returned when unable to find converter. ErrUnableToFindConverter = errors.New("unable to find converter") // ErrValueDoesntImplementProtoMessage is returned when value doesn't implement proto.Message. ErrValueDoesntImplementProtoMessage = errors.New("value doesn't implement proto.Message") // ErrValueDoesntImplementProtoUnmarshaler is returned when value doesn't implement proto.Unmarshaler. ErrValueDoesntImplementProtoUnmarshaler = errors.New("value doesn't implement proto.Unmarshaler") // ErrValueIsNotPointer is returned when value is not a pointer. ErrValueIsNotPointer = errors.New("value is not a pointer") )
Functions ¶
This section is empty.
Types ¶
type ByteSlicePayloadConverter ¶
type ByteSlicePayloadConverter struct { }
ByteSlicePayloadConverter pass through []byte to Data field in payload.
func NewByteSlicePayloadConverter ¶
func NewByteSlicePayloadConverter() *ByteSlicePayloadConverter
NewByteSlicePayloadConverter creates new instance of ByteSlicePayloadConverter.
func (*ByteSlicePayloadConverter) Encoding ¶
func (c *ByteSlicePayloadConverter) Encoding() string
Encoding returns MetadataEncodingBinary.
func (*ByteSlicePayloadConverter) FromPayload ¶
func (c *ByteSlicePayloadConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
FromPayload converts single []byte value from payload.
type CompositeDataConverter ¶
type CompositeDataConverter struct {
// contains filtered or unexported fields
}
CompositeDataConverter applies PayloadConverters in specified order.
func GetDefaultDataConverter ¶
func GetDefaultDataConverter() *CompositeDataConverter
GetDefaultDataConverter returns default data converter used by Temporal worker.
func NewCompositeDataConverter ¶
func NewCompositeDataConverter(payloadConverters ...PayloadConverter) *CompositeDataConverter
NewCompositeDataConverter creates new instance of CompositeDataConverter from ordered list of PayloadConverters. Order is important here because during serialization DataConverter will try PayloadsConverters in that order until PayloadConverter returns non nil payload. Last PayloadConverter should always serialize the value (JSONPayloadConverter is good candidate for it).
func (*CompositeDataConverter) FromPayload ¶
func (dc *CompositeDataConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
FromPayload converts single value from payload.
func (*CompositeDataConverter) FromPayloads ¶
func (dc *CompositeDataConverter) FromPayloads(payloads *commonpb.Payloads, valuePtrs ...interface{}) error
FromPayloads converts to a list of values of different types.
func (*CompositeDataConverter) ToPayload ¶
func (dc *CompositeDataConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
ToPayload converts single value to payload.
func (*CompositeDataConverter) ToPayloads ¶
func (dc *CompositeDataConverter) ToPayloads(values ...interface{}) (*commonpb.Payloads, error)
ToPayloads converts a list of values.
type DataConverter ¶
type DataConverter interface { // ToPayload converts single value to payload. ToPayload(value interface{}) (*commonpb.Payload, error) // FromPayload converts single value from payload. FromPayload(payload *commonpb.Payload, valuePtr interface{}) error // ToPayloads converts a list of values. ToPayloads(value ...interface{}) (*commonpb.Payloads, error) // FromPayloads converts to a list of values of different types. // Useful for deserializing arguments of function invocations. FromPayloads(payloads *commonpb.Payloads, valuePtrs ...interface{}) error // ToString converts payload object into human readable string. ToString(input *commonpb.Payload) string // ToStrings converts payloads object into human readable strings. ToStrings(input *commonpb.Payloads) []string }
DataConverter is used by the framework to serialize/deserialize input and output of activity/workflow that need to be sent over the wire. To encode/decode workflow arguments, set DataConverter in client, through client.Options. To override DataConverter for specific activity or child workflow use workflow.WithDataConverter to create new Context, and pass that context to ExecuteActivity/ExecuteChildWorkflow calls. Temporal support using different DataConverters for different activity/childWorkflow in same workflow.
type EncodedValue ¶
type EncodedValue interface { // HasValue return whether there is value encoded. HasValue() bool // Get extract the encoded value into strong typed value pointer. Get(valuePtr interface{}) error }
EncodedValue is used to encapsulate/extract encoded value from workflow/activity.
type EncodedValues ¶
type EncodedValues interface { // HasValues return whether there are values encoded. HasValues() bool // Get extract the encoded values into strong typed value pointers. Get(valuePtr ...interface{}) error }
EncodedValues is used to encapsulate/extract encoded one or more values from workflow/activity.
type JSONPayloadConverter ¶
type JSONPayloadConverter struct { }
JSONPayloadConverter converts to/from JSON.
func NewJSONPayloadConverter ¶
func NewJSONPayloadConverter() *JSONPayloadConverter
NewJSONPayloadConverter creates new instance of JSONPayloadConverter.
func (*JSONPayloadConverter) Encoding ¶
func (c *JSONPayloadConverter) Encoding() string
Encoding returns MetadataEncodingJSON.
func (*JSONPayloadConverter) FromPayload ¶
func (c *JSONPayloadConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
FromPayload converts single value from payload.
type NilPayloadConverter ¶
type NilPayloadConverter struct { }
NilPayloadConverter doesn't set Data field in payload.
func NewNilPayloadConverter ¶
func NewNilPayloadConverter() *NilPayloadConverter
NewNilPayloadConverter creates new instance of NilPayloadConverter.
func (*NilPayloadConverter) Encoding ¶
func (c *NilPayloadConverter) Encoding() string
Encoding returns MetadataEncodingNil.
func (*NilPayloadConverter) FromPayload ¶
func (c *NilPayloadConverter) FromPayload(_ *commonpb.Payload, valuePtr interface{}) error
FromPayload converts single nil value from payload.
type PayloadConverter ¶
type PayloadConverter interface { // ToPayload converts single value to payload. It should return nil if the PayloadConveter can not convert passed value (i.e. type is unknown). ToPayload(value interface{}) (*commonpb.Payload, error) // FromPayload converts single value from payload. valuePtr should be a reference to the variable of the type that is corresponding for payload encoding. // Otherwise it should return error. FromPayload(payload *commonpb.Payload, valuePtr interface{}) error // ToString converts payload object into human readable string. ToString(*commonpb.Payload) string // Encoding returns encoding supported by PayloadConverter. Encoding() string }
PayloadConverter is an interface to convert a single payload.
type ProtoJSONPayloadConverter ¶
type ProtoJSONPayloadConverter struct {
// contains filtered or unexported fields
}
ProtoJSONPayloadConverter converts proto objects to/from JSON.
func NewProtoJSONPayloadConverter ¶
func NewProtoJSONPayloadConverter() *ProtoJSONPayloadConverter
NewProtoJSONPayloadConverter creates new instance of ProtoJSONPayloadConverter.
func (*ProtoJSONPayloadConverter) Encoding ¶
func (c *ProtoJSONPayloadConverter) Encoding() string
Encoding returns MetadataEncodingProtoJSON.
func (*ProtoJSONPayloadConverter) FromPayload ¶
func (c *ProtoJSONPayloadConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
FromPayload converts single proto value from payload.
type ProtoPayloadConverter ¶
type ProtoPayloadConverter struct { }
ProtoPayloadConverter converts proto objects to protobuf binary format.
func NewProtoPayloadConverter ¶
func NewProtoPayloadConverter() *ProtoPayloadConverter
NewProtoPayloadConverter creates new instance of ProtoPayloadConverter.
func (*ProtoPayloadConverter) Encoding ¶
func (c *ProtoPayloadConverter) Encoding() string
Encoding returns MetadataEncodingProto.
func (*ProtoPayloadConverter) FromPayload ¶
func (c *ProtoPayloadConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error
FromPayload converts single proto value from payload.