Skip to main content

Interface: DataConverter

worker.DataConverter

Used by the framework to serialize/deserialize method parameters that need to be sent over the wire.

Implement this in order to customize worker data serialization or use the default data converter which supports Uint8Array and JSON serializables.

Implemented by#

Methods#

fromPayload#

fromPayload<T>(payload): Promise<T>

Type parameters#

Name
T

Parameters#

NameType
payloadIPayload

Returns#

Promise<T>


fromPayloadSync#

fromPayloadSync<T>(payload): T

Sync conversion from a single payload, used in the Workflow runtime

Type parameters#

Name
T

Parameters#

NameType
payloadIPayload

Returns#

T


fromPayloads#

fromPayloads<T>(index, content?): Promise<T>

Implements conversion of an array of values of different types. Useful for deserializing arguments of function invocations.

throws DataConverterError if conversion of the data passed as parameter failed for any reason.

Type parameters#

Name
T

Parameters#

NameTypeDescription
indexnumberindex of the value in the payloads
content?null | IPayload[]serialized value to convert to JS values.

Returns#

Promise<T>

converted JS value


fromPayloadsSync#

fromPayloadsSync<T>(index, content?): T

Sync version of fromPayloads

Type parameters#

Name
T

Parameters#

NameType
indexnumber
content?null | IPayload[]

Returns#

T


toPayload#

toPayload<T>(value): Promise<IPayload>

Type parameters#

Name
T

Parameters#

NameType
valueT

Returns#

Promise<IPayload>


toPayloadSync#

toPayloadSync<T>(value): IPayload

Sync conversion of single payload, used in the Workflow runtime

Type parameters#

Name
T

Parameters#

NameType
valueT

Returns#

IPayload


toPayloads#

toPayloads(...values): Promise<undefined | IPayload[]>

Implements conversion of a list of values.

throws DataConverterError if conversion of the value passed as parameter failed for any reason.

Parameters#

NameTypeDescription
...valuesunknown[]JS values to convert to Payloads.

Returns#

Promise<undefined | IPayload[]>

converted value


toPayloadsSync#

toPayloadsSync(...values): undefined | IPayload[]

Sync conversion of all arguments, used in the Workflow runtime

Implements conversion of a list of values.

throws DataConverterError if conversion of the value passed as parameter failed for any reason.

Parameters#

NameTypeDescription
...valuesunknown[]JS values to convert to Payloads.

Returns#

undefined | IPayload[]

converted value